#include <bits/stdc++.h>
using namespace std;
int main() {
  int seq[60];
  int yea[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  for (int i = 1; i <= 12; i++) {
    seq[i - 1] = yea[i - 1];
    seq[12 + i - 1] = yea[i - 1];
    seq[24 + i - 1] = yea[i - 1];
    seq[36 + i - 1] = yea[i - 1];
    seq[48 + i - 1] = yea[i - 1];
  }
  seq[25] = 29;
  int n;
  cin >> n;
  int que[n];
  for (int i = 0; i < n; i++) {
    cin >> que[i];
  }
  int k = 0;
  for (int i = 0; i < 60; i++) {
    if (seq[i] == que[0]) {
      int j = 1;
      for (j = 1; j < n; j++) {
        if (seq[i + j] != que[j]) break;
      }
      if (j == n) {
        k = 1;
      }
    }
    if (k == 1) break;
  }
  if (k == 1)
    cout << "Yes";
  else
    cout << "No";
}
