#include <bits/stdc++.h>
using namespace std;
int power(int x, int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
const int dx[] = {1, 1, 1, 0, 0, -1, -1, -1},
          dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main() {
  int n, m, s = 0, x = 0, y, p = 0;
  cin >> n;
  long long a[12], b[n];
  a[0] = 31;
  a[1] = 28;
  a[2] = 31;
  a[3] = 30;
  a[4] = 31;
  a[5] = 30;
  a[6] = 31;
  a[7] = 31;
  a[8] = 30;
  a[9] = 31;
  a[10] = 30;
  a[11] = 31;
  for (int i = 0; i < n; i++) cin >> b[i];
  if (n == 1) {
    if (b[0] < 28 || b[0] >= 32)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  } else {
    for (int i = 0; i < 24; i++) {
      y = 0;
      x = i;
      for (int k = 0; k < n; k++) {
        if (b[k] == 29 && p == 0) {
          b[k] = 28;
          p = 1;
        }
        if (b[k] == 29 && p == 1) {
          cout << "No" << endl;
          return 0;
        }
        x = x % 12;
        if (b[k] != a[x++]) {
          y = 1;
          break;
        }
      }
      if (y == 0) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }
}
