#include <bits/stdc++.h>
using namespace std;
int main() {
  int m1[100] = {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, 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};
  int n;
  cin >> n;
  int a[100];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sk = 0, kint = 0;
  for (int i = 0; i < 72; i++) {
    if (m1[i] == a[0]) {
      for (int j = i; j < i + n; j++) {
        if (a[sk] == m1[j]) {
          kint++;
          sk++;
        }
      }
      if (kint == n) {
        cout << "Yes";
        return 0;
        break;
      } else {
        sk = 0;
        kint = 0;
      }
    }
  }
  cout << "No";
  return 0;
}
