#include <bits/stdc++.h>
using namespace std;
int vis[] = {
    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, 29, 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, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
};
int main() {
  int n, a[40], i, j, f, ans;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (ans = i = 0; i < 72 - n; i++) {
    for (f = j = 0; j < n; j++) {
      if (a[j] != vis[j + i]) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      ans = 1;
      break;
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
