#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  cin >> n;
  int a[n + 5], c = 0, flag = 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 12; i++) {
    c = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] == x[(i + j) % 12])
        c++;
      else if (x[(i + j) % 12] == 28 && a[j] == 29 && flag) {
        c++;
        flag = 0;
      }
    }
    if (c == n) break;
  }
  cout << ((c == n) ? ("YES") : ("NO")) << endl;
  return 0;
}
