#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed;
  int n;
  cin >> n;
  int store[n];
  for (int i = 0; i < int(n); ++i) cin >> store[i];
  int third[] = {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, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int fourth[] = {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,
                  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int fifth[] = {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, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  bool flag = 0;
  int j = 0;
  for (int i = 0; i < 24; i++) {
    int k;
    for (k = i; k < i + n; k++) {
      if (third[k] == store[j]) {
        j++;
      } else
        break;
    }
    if (k == (i + n)) {
      flag = 1;
      break;
    }
    j = 0;
  }
  if (flag == 0) {
    for (int i = 0; i < 24; i++) {
      int k;
      for (k = i; k < i + n; k++) {
        if (fourth[k] == store[j]) {
          j++;
        } else
          break;
      }
      if (k == (i + n)) {
        flag = 1;
        break;
      }
      j = 0;
    }
  }
  if (flag == 0) {
    for (int i = 0; i < 24; i++) {
      int k;
      for (k = i; k < i + n; k++) {
        if (fifth[k] == store[j]) {
          j++;
        } else
          break;
      }
      if (k == (i + n)) {
        flag = 1;
        break;
      }
      j = 0;
    }
  }
  if (flag == 0)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
