#include <bits/stdc++.h>
using namespace std;
inline long long input() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long maxn = 1e5 + 10;
long long month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long a[maxn];
int32_t main() {
  long long n = in();
  for (long long i = 0; i < n; i++) a[i] = in();
  for (long long start = 0; start < 12; start++) {
    long long cur = start;
    bool used = false;
    bool fl = true;
    for (long long pt = 0; pt < n; pt++) {
      if (month[cur] != a[pt]) {
        if (cur != 1) {
          fl = false;
          break;
        } else if (used == false && a[pt] == 29) {
          used = true;
        } else {
          fl = false;
          break;
        }
      }
      cur = cur + 1;
      if (cur == 12) cur = 0;
    }
    if (fl) return cout << "Yes\n", 0;
  }
  cout << "No\n";
}
