#include <bits/stdc++.h>
int main() {
  int n, q, s, s1, w, z;
  int n1[36] = {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};
  int a[24];
  while (scanf("%d", &n) != EOF) {
    s = 0;
    q = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 29) {
        a[i] = 28;
        q++;
      }
      s += a[i];
    }
    if (q == 2) {
      printf("NO\n");
      break;
    } else {
      int t, count, r = 0;
      for (int i = 0; i < 48 - n; i++) {
        t = 0, count = 0;
        for (int j = i; j < n + i; j++) {
          if (n1[j] == a[t++]) {
            count++;
          }
        }
        if (count == n) {
          r = 1;
          break;
        }
      }
      if (r == 1)
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
  return 0;
}
