#include <bits/stdc++.h>
using namespace std;
long long balsal[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                           {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j, x, y, n, m, cnt = 0, k, g, flg, t, a, b;
  cin >> n;
  long long in[n + 2];
  for (i = 1; i <= n; i++) cin >> in[i];
  m = 0;
  for (a = 0; a <= 1; a++) {
    for (b = 0; b <= 11; b++) {
      y = a;
      m = b;
      flg = 1;
      for (i = 1; i <= n; i++) {
        if (in[i] != balsal[y][m]) {
          flg = 0;
          break;
        }
        m++;
        if (m > 11) {
          y++;
          y %= 2;
          m = 0;
        }
      }
      if (flg) {
        cout << "YES" << endl;
        return 0;
      }
      if (a == 1) continue;
      flg = 1;
      m = b;
      y = a;
      for (i = 1; i <= n; i++) {
        if (in[i] != balsal[y][m]) {
          flg = 0;
          break;
        }
        m++;
        if (m > 11) {
          m = 0;
        }
      }
      if (flg) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}
