#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\t';
  err(++it, args...);
}
const int N = 1e3;
int S[] = {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, 31, 29, 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, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int a[N];
int main() {
  int n, i, j = 0, k, p;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i <= 84 - n; i++) {
    bool is = 1;
    for (j = 0; j < n; j++) {
      if (a[j] != S[i + j]) {
        is = 0;
        break;
      }
    }
    if (is) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
