#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
int x1[48] = {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 x2[48] = {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 x3[48] = {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};
int x4[48] = {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};
int x5[11] = {31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> pos;
  for (int i = 0; i < 48 - n + 1; i++) {
    if (x1[i] == a[0]) pos.push_back(i);
  }
  for (int i = 0; i < pos.size(); i++) {
    int p = pos[i];
    bool ans = true;
    for (int j = 0; j < n; j++) {
      if (x1[p] != a[j]) {
        ans = false;
        break;
      }
      p++;
    }
    if (ans) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  pos.clear();
  for (int i = 0; i < 48 - n + 1; i++) {
    if (x2[i] == a[0]) pos.push_back(i);
  }
  for (int i = 0; i < pos.size(); i++) {
    int p = pos[i];
    bool ans = true;
    for (int j = 0; j < n; j++) {
      if (x2[p] != a[j]) {
        ans = false;
        break;
      }
      p++;
    }
    if (ans) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  pos.clear();
  for (int i = 0; i < 48 - n + 1; i++) {
    if (x3[i] == a[0]) pos.push_back(i);
  }
  for (int i = 0; i < pos.size(); i++) {
    int p = pos[i];
    bool ans = true;
    for (int j = 0; j < n; j++) {
      if (x3[p] != a[j]) {
        ans = false;
        break;
      }
      p++;
    }
    if (ans) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  pos.clear();
  for (int i = 0; i < 48 - n + 1; i++) {
    if (x4[i] == a[0]) pos.push_back(i);
  }
  for (int i = 0; i < pos.size(); i++) {
    int p = pos[i];
    bool ans = true;
    for (int j = 0; j < n; j++) {
      if (x4[p] != a[j]) {
        ans = false;
        break;
      }
      p++;
    }
    if (ans) {
      cout << "YES"
           << "\n";
      return 0;
    }
  }
  pos.clear();
  cout << "NO"
       << "\n";
  return 0;
}
