#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v1 = {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};
  vector<int> v2 = {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};
  int n;
  cin >> n;
  vector<int> v(n);
  for (int& x : v) cin >> x;
  int fl = 0;
  for (int i = 0; i < v1.size(); ++i) {
    if (v[0] == v1[i]) {
      int f = 0;
      int is = i;
      while (f < v.size() and i < v1.size() and v[f] == v1[i]) {
        ++f;
        ++i;
      }
      if (f == n) {
        cout << "Yes";
        fl = 1;
        return 0;
      }
      i = is;
    }
  }
  for (int i = 0; i < v2.size(); ++i) {
    if (v[0] == v2[i]) {
      int f = 0;
      int is = i;
      while (f < v.size() and i < v2.size() and v[f] == v2[i]) {
        ++f;
        ++i;
      }
      if (f == n) {
        cout << "Yes";
        fl = 1;
        return 0;
      }
      i = is;
    }
  }
  cout << "No";
}
