#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> M = {
      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, 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,
  };
  vector<int> A(n);
  for (int& x : A) cin >> x;
  for (int i = 0; i + n <= M.size(); i++) {
    bool OK = true;
    for (int j = 0; j < n; j++)
      if (A[j] != M[i + j]) OK = false;
    if (OK) return cout << "Yes\n", 0;
  }
  cout << "No\n";
}
