#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int b[200005];     vector<int> a;     cin >> n;     a.push_back(31);     a.push_back(28);     a.push_back(31);     a.push_back(30);     a.push_back(31);     a.push_back(30);     a.push_back(31);     a.push_back(31);     a.push_back(30);     a.push_back(31);     a.push_back(30);     a.push_back(31);     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < 12; i++) {       int count = 0, f = 0;       for (int j = 0; j < n; j++) {         if ((i + j) % 12 == 1) {           if (a[(i + j) % 12] == b[j])             continue;           else {             if (a[(i + j) % 12] == 28 && b[j] == 29 && count == 0) {               count = 1;               continue;             }           }         }         if (a[(i + j) % 12] != b[j]) {           f = 1;           break;         }       }       if (f == 0) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;     return 0;   }   