#include <bits/stdc++.h>
using namespace std;
int b[1000],
    a[] = {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, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    sum1, sum2, ans;
int main() {
  int n, p = 0, q = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < 48; i++) {
    for (int j = i; j < i + n; j++) {
      if (b[p] == a[j]) {
        q++;
        p++;
      } else
        break;
    }
    if (q == n) {
      cout << "YES";
      return 0;
    }
    p = 0;
    q = 0;
  }
  cout << "NO";
}
