#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, z;
  string a = "18101011010118101011010119101011010118101011010118101011010118101"
             "0110101191010110101181010110101",
         b = "";
  scanf("%d", &n);
  for (i = 0; i <= n - 1; i++) {
    scanf("%d", &z);
    b += z % 10 + 48;
  }
  if (a.find(b) == -1)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}
