#include <bits/stdc++.h>
using namespace std;
char a[] = {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, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s, ss;
int main() {
  int n, hahahahaha[25], pos;
  s = a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> hahahahaha[i];
    char gggg = (char)hahahahaha[i];
    ss.push_back(gggg);
  }
  pos = s.find(ss);
  if (pos >= 0)
    printf("YES\n");
  else
    printf("NO\n");
}
