#include <bits/stdc++.h>
using namespace std;
const string sc =
    "31293130313031313031303131283130313031313031303131283130313031313031303131"
    "28313031303131303130313128313031303131303130331293130313031313031303131283"
    "13031303131303130313128313031303131303130313128313031303131303130313128313"
    "03130313130313031312931303130313130313031312831303130313130313031312831303"
    "13031313031303131283130313031313031303131283130313031313031303131293130313"
    "0313130313031";
int n;
string st, str;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> st;
    str += st;
  }
  if (sc.find(str) == string::npos) {
    cout << "No";
  } else {
    cout << "Yes";
  }
  return 0;
}
