#include <bits/stdc++.h>
using namespace std;
string s =
    "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,";
string ss;
int main(void) {
  std::ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  string ans = "";
  while (n--) {
    cin >> ss;
    ans += ss;
    ans += ",";
  }
  if (s.find(ans) != string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
