#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int days[] = {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};
  int days1[] = {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};
  int days2[] = {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};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  bool flag = 0;
  for (int j = 0; j < 36 - n + 1; j++) {
    bool f = 1;
    int i = 0;
    for (int k = j; k < j + n; k++) {
      if (a[i] != days[k]) {
        f = 0;
        break;
      }
      i++;
    }
    if (f) {
      flag = 1;
      break;
    }
  }
  for (int j = 0; j < 36 - n + 1; j++) {
    bool f = 1;
    int i = 0;
    for (int k = j; k < j + n; k++) {
      if (a[i] != days1[k]) {
        f = 0;
        break;
      }
      i++;
    }
    if (f) {
      flag = 1;
      break;
    }
  }
  for (int j = 0; j < 36 - n + 1; j++) {
    bool f = 1;
    int i = 0;
    for (int k = j; k < j + n; k++) {
      if (a[i] != days2[k]) {
        f = 0;
        break;
      }
      i++;
    }
    if (f) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}
