#include <bits/stdc++.h>
using namespace std;
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int L[][2] = {{0, 0}, {1, 0}, {0, 1}};
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  for (int i = (0); i < (n); i++) {
    int a;
    scanf("%d", &a);
    v.push_back(a);
  }
  bool ok = false;
  for (int start = (0); start < (12); start++)
    for (int leap = (0); leap < (3); leap++) {
      bool match = true;
      for (int i = (0); i < (((int)(v).size())); i++) {
        int target = M[(start + i) % 12];
        if ((start + i) % 12 == 1 && L[leap][i / 12]) ++target;
        if (target != v[i]) match = false;
      }
      ok |= match;
    }
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
}
