#include <bits/stdc++.h>
using namespace std;
int m1[] = {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 m2[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
            31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int m3[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, a[100], i, k;
bool exist, check;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  exist = false;
  for (int k = 0; k < 24; k++) {
    check = true;
    for (int i = 0; i < n; i++)
      if (m1[(i + k) % 24] != a[i]) {
        check = false;
        break;
      }
    if (check) {
      exist = true;
      break;
    }
  }
  for (int k = 0; k < 24; k++) {
    check = true;
    for (int i = 0; i < n; i++)
      if (m2[(i + k) % 24] != a[i]) {
        check = false;
        break;
      }
    if (check) {
      exist = true;
      break;
    }
  }
  for (int k = 0; k < 12; k++) {
    check = true;
    for (int i = 0; i < n; i++)
      if (m3[(i + k) % 12] != a[i]) {
        check = false;
        break;
      }
    if (check) {
      exist = true;
      break;
    }
  }
  if (exist)
    cout << "YES";
  else
    cout << "NO";
}
