#include <bits/stdc++.h>
using namespace std;
int a[100], b[100] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
            c[100] = {-1, 29, -1, -1, -1, -1, -1, -1, -1,
                      -1, -1, -1, -1, -1, -1, -1, -1, -1};
int cnt[100];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      ++cnt[a[i]];
    }
    bool f = 0;
    for (int i = 0; i < 12; ++i) {
      bool l = 1;
      for (int j = 0; j < n; ++j) {
        if (a[j] != b[(i + j) % 12] && a[j] != c[(i + j) % 12]) l = 0;
      }
      if (l) {
        f = 1;
        break;
      }
    }
    if (f && cnt[29] < 2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
