#include <bits/stdc++.h>
using namespace std;
int a[72] = {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};
int b[30];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int j = 0; j < 60 - n; j++) {
    bool ok = true;
    for (int i = 1; i <= n; i++)
      if (a[j + i - 1] != b[i]) {
        ok = false;
        break;
      }
    if (ok) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
