#include <bits/stdc++.h>
const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char to_string(int x) {
  switch (x) {
    case 28:
      return 'A';
    case 29:
      return 'B';
    case 30:
      return 'C';
    case 31:
      return 'D';
  }
}
std::string startup() {
  std::string ans;
  for (int y = 0; y < 400; y++) {
    for (int m = 1; m <= 12; m++) {
      if ((m == 2) && ((y == 0) || ((y % 4 == 0) && (y % 100 != 0)))) {
        ans = ans + to_string(29);
      } else
        ans = ans + to_string(days[m]);
    }
  }
  return ans;
}
int main() {
  std::string possible = startup();
  possible = possible + possible;
  std::string in;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    std::cin >> x;
    in = in + to_string(x);
  }
  if (possible.find(in) != -1)
    std::cout << "YES";
  else
    std::cout << "NO";
  return 0;
}
