#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, i, j, arr[25];
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> arr[i];
  int a[24] = {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[24] = {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 c[24] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
               31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  for (int i = 0; i < (24); i++) {
    bool flag = 0;
    for (int j = 0; j < (n); j++) {
      if (a[(i + j) % 24] != arr[j]) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      cout << "YES";
      return 0;
    }
  }
  for (int i = 0; i < (24); i++) {
    bool flag = 0;
    for (int j = 0; j < (n); j++) {
      if (b[(i + j) % 24] != arr[j]) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      cout << "YES";
      return 0;
    }
  }
  for (int i = 0; i < (24); i++) {
    bool flag = 0;
    for (int j = 0; j < (n); j++) {
      if (c[(i + j) % 24] != arr[j]) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
