#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Max(const T &x, const T &y) {
  return x < y ? y : x;
}
template <typename T>
T Min(const T &x, const T &y) {
  return x < y ? x : y;
}
template <typename T>
int chkmax(T &x, const T &y) {
  return x < y ? (x = y, 1) : 0;
}
template <typename T>
int chkmin(T &x, const T &y) {
  return x > y ? (x = y, 1) : 0;
}
template <typename T>
void read(T &x) {
  T f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
const int maxn = 1010;
const int day[maxn] = {0,  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                       31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31,
                       28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, a[maxn];
bool c;
bool check(int x, int y) {
  if (x == 29 && c) return false;
  if (x == 29) x--, c = true;
  return x == y;
}
int main() {
  read(n);
  for (int i = (1), iend = (n); i <= iend; ++i) read(a[i]);
  bool flag = false;
  for (int i = (1), iend = (12); i <= iend; ++i) {
    bool f = true;
    c = false;
    for (int j = (1), jend = (n); j <= jend; ++j)
      if (!check(a[j], day[i + j - 1])) {
        f = false;
        break;
      }
    if (f) {
      flag = true;
      break;
    }
  }
  if (flag)
    puts("YES");
  else
    puts("NO");
  return 0;
}
