#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int m[72] = {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 a[1022];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < 72 - n; i++) {
    bool b = 1;
    for (int j = 0; j < n; j++)
      if (m[i + j] != a[j]) b = 0;
    if (b) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}
