#include <bits/stdc++.h>
using namespace std;
int days[] = {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};
int main() {
  int n, a[24];
  cin >> n;
  for (int j = 0; j < n; j++) cin >> a[j];
  for (int i = 0; i < 48; i++) {
    bool f = true;
    for (int j = 0; j < n; j++) {
      if (a[j] != days[(j + i) % 48]) f = false;
    }
    if (f) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
