#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[36] = {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 y[36] = {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};
  int z[36] = {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 t[36] = {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 w[24];
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &w[i]);
    }
    int count = 0;
    for (int i = 0; i < 36; i++) {
      if (x[i] == w[0] && count == 0) {
        for (int j = i; j < i + n; j++) {
          if (x[j] == w[j - i]) {
            count++;
          }
        }
      }
      if (count != n) {
        count = 0;
      }
    }
    for (int i = 0; i < 36; i++) {
      if (y[i] == w[0] && count == 0) {
        for (int j = i; j < i + n; j++) {
          if (y[j] == w[j - i]) {
            count++;
          }
        }
      }
      if (count != n) {
        count = 0;
      }
    }
    for (int i = 0; i < 36; i++) {
      if (z[i] == w[0] && count == 0) {
        for (int j = i; j < i + n; j++) {
          if (z[j] == w[j - i]) {
            count++;
          }
        }
      }
      if (count != n) {
        count = 0;
      }
    }
    for (int i = 0; i < 36; i++) {
      if (t[i] == w[0] && count == 0) {
        for (int j = i; j < i + n; j++) {
          if (t[j] == w[j - i]) {
            count++;
          }
        }
      }
      if (count != n) {
        count = 0;
      }
    }
    int u = 0;
    for (int i = 0; i < n; i++) {
      if (w[i] == 29) {
        u++;
      }
    }
    if (u >= 2) {
      count = 0;
    }
    if (count == n) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}
