#include <bits/stdc++.h>
using namespace std;
int main() {
  int m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int k = 0;
  int n;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < 12; i++) {
    bool a = true;
    k = 0;
    for (int j = 0, ii = i; j < n; j++, ii++) {
      if (A[j] == 29 && m[ii] == 28) {
        if (!k) {
          k = 1;
          continue;
        } else {
          a = false;
          break;
        }
      }
      if (ii == 12) ii = 0;
      if (A[j] != m[ii]) {
        a = false;
        break;
      }
    }
    if (a) return cout << "Yes", 0;
  }
  cout << "No";
}
