#include <bits/stdc++.h>
int main() {
  char a[] =
      "18101011010118101011010119101011010118101011010118101011010118101011010"
      "1";
  int n, i;
  int b[300];
  char c[300];
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d", &b[i]);
      if (b[i] == 28) c[i] = '8';
      if (b[i] == 29) c[i] = '9';
      if (b[i] == 30) c[i] = '0';
      if (b[i] == 31) c[i] = '1';
    }
    b[i] = '\0';
    if (strstr(a, c))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
