#include <bits/stdc++.h>
using namespace std;
int main() {
  string name =
      "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 test;
  int n;
  cin >> n;
  string t;
  while (n--) {
    cin >> t;
    test += t;
    test += " ";
  }
  if (name.find(test) != std::string::npos)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
