#include <bits/stdc++.h>
using namespace std;
int a[1000006];
bool ase = true;
vector<int> v, temp;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= 48; i++) {
    if (i % 12 == 1) v.push_back(31);
    if (ase && i % 12 == 2) {
      v.push_back(29);
      ase = false;
    } else if (!ase && i % 12 == 2)
      v.push_back(28);
    if (i % 12 == 3) v.push_back(31);
    if (i % 12 == 4) v.push_back(30);
    if (i % 12 == 5) v.push_back(31);
    if (i % 12 == 6) v.push_back(30);
    if (i % 12 == 7) v.push_back(31);
    if (i % 12 == 8) v.push_back(31);
    if (i % 12 == 9) v.push_back(30);
    if (i % 12 == 10) v.push_back(31);
    if (i % 12 == 11) v.push_back(30);
    if (i % 12 == 0) v.push_back(31);
  }
  bool ans = false;
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) temp.push_back(v[i]);
  for (int i = 0; i < temp.size(); i++) v.push_back(temp[i]);
  for (int i = 0; i < v.size(); i++) {
    cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (i + j >= v.size()) break;
      if (v[i + j] == a[j]) cnt++;
    }
    if (cnt == n) ans = true;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
