#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 29, M = 313, bghs = 1e9 + 7, inf = 1e18;
long long int a[maxn];
long long int mah[] = {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};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < 61 - n; i++) {
    long long int sz = 0;
    for (long long int j = 0; j < n; j++) {
      if (mah[i + j] == a[j]) sz++;
    }
    if (sz == n) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
}
