#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60) - 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m, i, ck = 0, a, b, j, k;
    string a1, a2, a3 = "", a4 = "", xx;
    a1 = "312831303130313130313031";
    a2 = "312931303130313130313031";
    a3 = a1 + a1 + a2 + a1 + a1;
    cin >> n;
    while (n--) {
      cin >> xx;
      a4 += xx;
    }
    if (a3.find(a4) != -1)
      cout << "Yes"
           << "\n";
    else
      cout << "No"
           << "\n";
  }
  cerr << "Time Taken:" << (float)clock() / CLOCKS_PER_SEC * 1000 << "ms"
       << "\n";
  return 0;
}
