#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int days[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> days[i];
  }
  int day[96] = {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};
  bool found = false;
  for (int i = 0; i <= 96 - n; i++) {
    bool possible = true;
    for (int j = 1; j <= n; j++) {
      if (days[j] != day[i + j - 1]) {
        possible = false;
      }
    }
    if (possible) {
      found = true;
      break;
    }
  }
  if (found) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;
}
