#include <bits/stdc++.h>
using namespace std;
bool solve(string st, string s) {
  long long i = 0, n = s.size(), k = st.size();
  for (i = 0; n - i >= k; i += 2) {
    if (s.substr(i, k) == st) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    string st;
    string d1 = "312831303130313130313031";
    string d2 = "312931303130313130313031";
    string s = d1 + d2 + d1 + d1 + d1 + d2;
    for (auto &it : a) {
      cin >> it;
      if (it == 28)
        st += "28";
      else if (it == 29)
        st += "29";
      else if (it == 30)
        st += "30";
      else
        st += "31";
    }
    if (n == 1)
      cout << "Yes" << endl;
    else if (solve(st, s))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
