#include <bits/stdc++.h>
using namespace std;
int arr[30];
int main() {
  int m1[] = {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, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < 72 - n + 1; i++) {
    int st = i, e = i + n - 1;
    int cnt = 0;
    for (int j = st, k = 0; j <= e; j++, k++) {
      if (m1[j] == arr[k]) cnt++;
    }
    if (cnt == n) return puts("YES");
  }
  printf("NO");
}
