#include <bits/stdc++.h>
using namespace std;
int day[4][48] = {
    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, 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, 28, 31, 30, 31, 30,
    31, 31, 30, 31, 30, 31, 31, 29, 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 a[30];
int main() {
  int n;
  cin >> n;
  int k = 1, vis_28, vis_29;
  vis_28 = vis_29 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (vis_28) k = 0;
  int flag = 0, x = 0, tmp;
  for (int k = 0; k < 4; k++) {
    while (x < 36) {
      if (day[k][x] == a[0]) {
        int i;
        for (i = 0; i < n; i++) {
          if (a[i] != day[k][(x + i) % 36]) break;
        }
        if (i == n) {
          flag = 1;
          break;
        }
      }
      x++;
    }
  }
  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
