#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[10005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 100; i++) b[i] = 30;
  b[1] = 31;
  b[2] = 28;
  b[3] = 31;
  b[5] = 31;
  b[7] = 31;
  b[8] = 31;
  b[10] = 31;
  b[12] = 31;
  b[1 + 12] = 31;
  b[2 + 12] = 29;
  b[3 + 12] = 31;
  b[5 + 12] = 31;
  b[7 + 12] = 31;
  b[8 + 12] = 31;
  b[10 + 12] = 31;
  b[12 + 12] = 31;
  b[1 + 24] = 31;
  b[2 + 24] = 28;
  b[3 + 24] = 31;
  b[5 + 24] = 31;
  b[7 + 24] = 31;
  b[8 + 24] = 31;
  b[10 + 24] = 31;
  b[12 + 24] = 31;
  b[1 + 36] = 31;
  b[2 + 36] = 28;
  b[3 + 36] = 31;
  b[5 + 36] = 31;
  b[7 + 36] = 31;
  b[8 + 36] = 31;
  b[10 + 36] = 31;
  b[12 + 36] = 31;
  b[1 + 48] = 31;
  b[2 + 48] = 28;
  b[3 + 48] = 31;
  b[5 + 48] = 31;
  b[7 + 48] = 31;
  b[8 + 48] = 31;
  b[10 + 48] = 31;
  b[12 + 48] = 31;
  b[1 + 60] = 31;
  b[2 + 60] = 29;
  b[3 + 60] = 31;
  b[5 + 60] = 31;
  b[7 + 60] = 31;
  b[8 + 60] = 31;
  b[10 + 60] = 31;
  b[12 + 60] = 31;
  int flag = 0;
  int i = 0;
  int cnt = 0;
  for (int j = 1; j <= 72; j++) {
    if (a[i] == b[j]) {
      i++;
      if (i == n) {
        flag = 1;
        break;
      }
    } else {
      cnt++;
      i = 0;
      j = cnt;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
