#include <bits/stdc++.h>
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
int main() {
  int a[60] = {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, 29, 31, 30, 31, 30, 31, 31, 30,
               31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int n;
  cin >> n;
  int b[n];
  for (int i = 0; i < n; i++) cin >> b[i];
  bool u;
  for (int i = 0; i < 60 - n; i++) {
    u = true;
    for (int j = i; j < i + n; j++) {
      if (a[j] != b[j - i]) {
        u = false;
        break;
      }
    }
    if (u) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
