#include <bits/stdc++.h>
using namespace std;
int main() {
  string s =
      "312831303130313130313031312931303130313130313031312831303130313130313031"
      "312831303130313130313031312831303130313130313031312931303130313130313031"
      "312831303130313130313031312831303130313130313031";
  string x, y;
  int n, i, p;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> y;
    x += y;
  }
  if (s.find(x) != -1) {
    p = 1;
  } else {
    p = 0;
  }
  if (p == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
