#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
int a1[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int a2[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string str1 =
    "31293130313031313031303131283130313031313031303131283130313031313031303131"
    "2831303130313130313031";
string str2 =
    "31283130313031313031303131293130313031313031303131283130313031313031303131"
    "2831303130313130313031";
string str3 =
    "31283130313031313031303131283130313031313031303131293130313031313031303131"
    "2831303130313130313031";
string str4 =
    "31283130313031313031303131283130313031313031303131283130313031313031303131"
    "2931303130313130313031";
int a[25];
int num[90] = {0};
int main() {
  int n;
  cin >> n;
  string str, data;
  for (int i = 0; i < n; i++) {
    cin >> data;
    str += data;
  }
  if (str1.find(str) < str1.length() || str2.find(str) < str2.length() ||
      str3.find(str) < str3.length() || str4.find(str) < str4.length()) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
