Everybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, 30 in June, 31 in July, 31 in August, 30 in September, 31 in October, 30 in November, 31 in December.A year is leap in one of two cases: either its number is divisible by 4, but not divisible by 100, or is divisible by 400. For example, the following years are leap: 2000, 2004, but years 1900 and 2018 are not leap.In this problem you are given n (1 ≤ n ≤ 24) integers a1, a2, ..., an, and you have to check if these integers could be durations in days of n consecutive months, according to Gregorian calendar. Note that these months could belong to several consecutive years. In other words, check if there is a month in some year, such that its duration is a1 days, duration of the next month is a2 days, and so on.

The first line contains single integer n (1 ≤ n ≤ 24) — the number of integers. The second line contains n integers a1, a2, ..., an (28 ≤ ai ≤ 31) — the numbers you are to check.

If there are several consecutive months that fit the sequence, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can print each letter in arbitrary case (small or large).

NoteIn the first example the integers can denote months July, August, September and October.In the second example the answer is no, because there are no two consecutive months each having 30 days.In the third example the months are: February (leap year) — March — April – May — June.In the fourth example the number of days in the second month is 28, so this is February. March follows February and has 31 days, but not 30, so the answer is NO.In the fifth example the months are: December — January — February (non-leap year).

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int b[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

            int n = in.scanInt();
            int r[] = new int[n];
            in.scanInt(r, n);
            for (int i = 0; i < a.length; i++) {
                int temp = i, j = 0;
                int count = 0;
                while (j < n && (a[temp] == r[j] || b[temp] == r[j])) {
                    if (r[j] == 29) count++;
                    temp++;
                    j++;
                    temp %= a.length;
                }
                if (j == n && count < 2) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public void scanInt(int[] A, int size) {
            for (int i = 0; i < size; i++) A[i] = scanInt();
        }

    }
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());

        int[] months = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int[] compare = new int[n];
        int index = 0;
        int leapCount = 0;
        while(n-->0){
            int a = Integer.parseInt(st.nextToken());
            compare[index++] = a == 29 ? 28 : a;
            leapCount += a == 29 ? 1 : 0;
        }

        if(leapCount > 1){
            System.out.println("No");
            return;
        }

        for(int i = 0; i<12; i++){
            if(months[i] != compare[0])
                continue;
            int currMonthIndex = i;
            boolean found = true;
            for(int j = 0; j<compare.length; j++){
                int val = compare[j];
                if(val != months[currMonthIndex])
                    found = false;
                currMonthIndex++;
                currMonthIndex%=months.length;
            }
            if(found){
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] year = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            for (int i = 0; i < 12; i++) {
                int fabDif = 0;
                int dif = 0;
                for (int j = 0; j < n; j++) {
                    if (a[j] != year[(j + i) % 12]) {
                        dif++;
                        if ((j + i) % 12 == 1 && a[j] == 29) fabDif++;
                    }
                }
                if (dif == 0) {
                    out.println("Yes");
                    return;
                }
                if (dif == 1 && fabDif == 1) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }

    static class InputReader {
        private StringTokenizer tokenizer;
        private BufferedReader reader;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private void fillTokenizer() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        public String next() {
            fillTokenizer();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/** Class for buffered reading int and double values */
public class A{
    public static void main(String[] args) throws IOException {
        Reader.init( System.in ); // connect Reader to an input stream
        //double x = Reader.nextDouble();
        //String s = Reader.next();
        int n = Reader.nextInt();
        //long ax = Reader.nextLong();
        int[] arr = new int[n];
        int count1 = 0;

        int[] arr2 = {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[] arr1 = {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[] arr3 = {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[] arr4 = {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};
        for(int i =0 ; i<n; i++) {
            arr[i] = Reader.nextInt();
        }
        int count = 0;

        for (int j = 0; j<36-n;j++) {
            int[] newArray = Arrays.copyOfRange(arr1, j, j+n);
            int[] newArray2 = Arrays.copyOfRange(arr2, j, j+n);

            int[] newArray3 = Arrays.copyOfRange(arr3, j, j+n);
            int[] newArray4 = Arrays.copyOfRange(arr4, j, j+n);

            if(Arrays.equals(arr, newArray) || Arrays.equals(arr, newArray2) || Arrays.equals(arr, newArray3) || Arrays.equals(arr, newArray4)){
               count ++;
            }
        }
        if (count>0){
            System.out.println("yes");
        }
        else{
            System.out.println("no");
        }
    }

    static void parr(int[] array,String seperator){
        String sep  = "";
        for(int var : array){
            System.out.print(sep + var);
            sep = seperator;
        }
        System.out.println();
    }

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    static String nextToken() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() {
        return Long.parseLong(nextToken());
    }

}

import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        PrintWriter cout = new PrintWriter(System.out, true);
        Scanner cin = new Scanner(System.in);

        StringBuilder res = new StringBuilder();

        int n = cin.nextInt();

        String test = "";

        String normal="31 28 31 30 31 30 31 31 30 31 30 31 ";
        String leap="31 29 31 30 31 30 31 31 30 31 30 31 ";

        for (int i = 0; i < n; i++) {
            test += cin.next() + " ";
        }

        String years = normal+leap+normal+normal+normal+leap+normal+normal;

        int len = years.length();

        years = years.replace(test, "");

        cout.println(years.length()<len?"Yes":"No");
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Months_and_years solver = new Months_and_years();
        solver.solve(1, in, out);
        out.close();
    }

    static class Months_and_years {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int tempArr1[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int tempArr2[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int n = in.scanInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) arr[i] = in.scanInt();

            for (int i = 0; i < tempArr1.length; i++) {
                int j = 0;
                int temp = i;
                int c = 0;
                while (j < n && (tempArr1[temp] == arr[j] || arr[j] == tempArr2[temp])) {
                    if (arr[j] == 29) c++;

                    j++;
                    temp = (temp + 1) % tempArr1.length;
                }

                if (j == n && c < 2) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                    ;
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

import java.io.*;
import java.util.*;
public class Main
{

	private void solve()throws Exception
	{
		int bothnonleap[]={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 firstleap[]={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 secondleap[]={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 thirdleap[]={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 n=nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=nextInt();

		outer: for(int i=0;i<12;i++)
		{
			for(int j=0;j<n;j++)
				if(bothnonleap[i+j]!=a[j])
					continue outer;
			out.println("Yes");
			return;
		}
		outer: for(int i=0;i<12;i++)
		{
			for(int j=0;j<n;j++)
				if(firstleap[i+j]!=a[j])
					continue outer;
			out.println("Yes");
			return;
		}
		outer: for(int i=0;i<12;i++)
		{
			for(int j=0;j<n;j++)
				if(secondleap[i+j]!=a[j])
					continue outer;
			out.println("Yes");
			return;
		}
		outer: for(int i=0;i<12;i++)
		{
			for(int j=0;j<n;j++)
				if(thirdleap[i+j]!=a[j])
					continue outer;
			out.println("Yes");
			return;
		}
		out.println("No");
	}

	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static final String FILE_NAME = "in";

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream(FILE_NAME + ".in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream(FILE_NAME + ".out");

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);
    private final int MOD = (int) (1e9 + 7);
    private final int MOD1 = (int) (1e6 + 3);
    private final long INF_LONG = (long) (1e18 + 1);
    private final double EPS = 1e-9;

    private long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    private long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    private boolean test(int[] a, int[] c, int[] c1, int pos, int count) {
        int[] x = new int[c.length * count];

        int t = 0;
        for (int i = 0; i < pos; i++) {
            for (int j = 0; j < c.length; j++) {
                x[t + j] = c[j];

            }
            t += c.length;
        }
        for (int i = 0; i < c1.length; i++) {
            x[t + i] = c1[i];
        }
        t += c1.length;
        for (int i = pos + 1; i < count; i++) {
            for (int j = 0; j < c.length; j++) {
                x[t + j] = c[j];

            }
            t += c.length;
        }

        for (int i = 0; i + a.length < x.length; i++) {
            boolean fl = true;
            for (int j = 0; j < a.length; j++) {
                if (a[j] != x[i + j]) {
                    fl = false;
                }
            }
            if (fl) {
                return true;
            }
        }

        return false;
    }

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int[] c = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int[] c1 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int n = in.nextInt();
        int[] a = in.nextArrayInt(n);

        for (int i = 0; i < 4; i++) {
            boolean fl = test(a, c, c1, i, 4);
            if (fl) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int[] nextArrayInt(int count) {
        return nextArrayInt(0, count);
    }

    public int[] nextArrayInt(int start, int count) {
        int[] a = new int[start + count];
        for (int i = start; i < start + count; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextArrayLong(int count) {
        long[] a = new long[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextLong();
        }
        return a;
    }
}

import java.util.HashSet;
import java.util.Scanner;

public class B {

	static int[] poss = new int[] {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 };

	static HashSet<Integer> odd = new HashSet<Integer>();
	static HashSet<Integer> even = new HashSet<Integer>();

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();

		int mon[] = new int[n];

		for(int i = 0; i < n; ++i) mon[i] = in.nextInt();

		check(mon);

		in.close();
	}

	static void check(int[] a) {
		for(int i = 0; i < poss.length; ++i) {

			int j = 0;
			int ii = i;

			while(a[j] == poss[ii]) {
				j++;
				ii++;
				if(ii == poss.length || j == a.length) break;
			}
			if(j == a.length) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		int N = input.nextInt();

		int[] sequence = {
						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};

		Queue<Integer> pq = new LinkedList<Integer>();

		for (int i = 0; i < N; i++) {
			int num = input.nextInt();
			if (i == 0) {
				for (int state = 0; state < sequence.length; state++)
					if (sequence[state] == num)
						pq.add(state);
			} else {
				LinkedList<Integer> next = new LinkedList<>();
				while (!pq.isEmpty()) {
					int state = pq.poll();
					if (state == sequence.length - 1) continue;
					if (sequence[state + 1] == num)
						next.add(state + 1);
				}
				pq.addAll(next);
			}
		}

		if (pq.isEmpty())
			System.out.println("NO");
		else
			System.out.println("YES");
	}
}

import java.util.Scanner;

public class MonthsAndYears {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();scan.nextLine();
		String s=scan.nextLine();
		String normal="31 28 31 30 31 30 31 31 30 31 30 31 ";
		String leap="31 29 31 30 31 30 31 31 30 31 30 31 ";
		String key=normal+leap+normal+normal+normal+leap+normal+normal;
//		System.out.println(key);
		System.out.println(key.contains(s)?"YES":"NO");
	}
}

import java.io.*;
import java.util.*;
import java.util.regex.*;
public class vk18
{
    public static void main(String[]stp) throws Exception
    {
    	Scanner scan=new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String []s;
        String n=br.readLine();
        //for(i=0;i<n;i++) {k=scan.nextInt(); na+=""+k+" "; }
        String na=br.readLine();
        //System.out.println(na);
        String no="31 28 31 30 31 30 31 31 30 31 30 31";
        String leap="31 29 31 30 31 30 31 31 30 31 30 31";
        String mix=no+" "+leap+" "+no+" "+no+" "+no+" "+no+" "+leap+" "+no;
        //System.out.println(mix);
        if(mix.contains(na)) {System.out.println("YES");  }
        else System.out.println("NO");

    }
}

import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final int[] Months=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
    public static void main(String[] arg){
        Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        while(in.hasNext()){
            int n=in.nextInt();
            ArrayList<Integer> vec=new ArrayList<>();
            for(int i=0;i<n;i++){
                vec.add(in.nextInt());
            }
            boolean result=false;
            for(int i=0;i<Months.length && !result ;i++){
                if(vec.get(0)==Months[i] || vec.get(0)== 29){
                    boolean isLoop=false;
                    for(int j=0,start=i;j<n;j++){
                        if((vec.get(j) == Months[start]) || (vec.get(j)==29 && start == 1 && !isLoop )){
                            isLoop = (vec.get(j) == 29 && start == 1) || isLoop;
                            start = (start+1) % Months.length;
                        }else{
                            break;
                        }
                        if(j==n-1){
                            result = true;
                        }
                    }
                }
            }
            out.println(result?"Yes":"No");
            out.flush();
        }
        in.close(); out.close();
    }
}

import java.io.*;
//import java.lang.reflect.Array;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class citylights {
    public static int[] arr;
    public static ArrayList<Integer> p;
    public static int[] val;
    public static long[] facto;
    public static long mod = 1000000007;
    public static long[] fillme;
    public static int ans = 0;
    public static int n, k;
    public static int [][]a;
    public static int []cnt=new int[27];
    static InputReader in;
    static PrintWriter out;
    public static HashSet<Long> hs=new HashSet<>();
    public static ArrayList<Integer> ar[];
    public static long x,y;
    public static long MOD= (long) (1e9+7);
    public static boolean []v;
    public static int []cal = {31,28,31,30,31,30,31,31,30,31,30,31};

//--------------------------------------My Code--------------------------------------------

    public static void main(String[] args) throws IOException {
        //arr = new int[1000001];
        //  p = new ArrayList<>();
        //  val = new int[1000001];
        // facto = new long[10000007];
        //tt=new int[100];
        //sieve();
        //  fact();
        //  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        InputReader in=new InputReader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        //Scanner in=new Scanner(System.in);

        int []curr = new int[60];

        int n =in.nextInt();
        for (int i=0;i<n;i++)
        {
            curr[i] = in.nextInt();
        }

        for (int year = 1000 ; year<=40000 ; year++)
        {
            int current = year;
            for (int i = 0 ;i<12;i++)
            {
                int m = i;
                boolean checker = false;
                for (int j = 0;j<n;j++)
                {
                    if(monthwala(current,m)!=curr[j])
                    {
                        checker = true;
                        break;
                    }
                    m++;
                    if(m==12)
                    {
                       m = 0;
                       current++;
                    }

                }
                if(!checker)
                {
                    out.println("Yes");
                    out.close();
                    return;
                }

            }
        }
        out.println("No");

        out.close();
    }

    static int monthwala(int year , int month)
    {
        if(month!=1)return cal[month];
        else if((year % 400 == 0) ||(year%4==0 && year%100!=0))return 29;
        else return 28;
    }
    //-------------------------------------------Code ends-------------------------------
static class people{
        String name;
        int region;
        int point;

        public people(String name, int region, int point) {
            this.name = name;
            this.region = region;
            this.point = point;
        }
    }
 static long getFactorial(long number) {
        long factorial = 1;
        for (long i = 1; i <= number; ++i) {
            factorial *= i;
        }
        return factorial;
    }
    public static void primeFactors(long n)
    {
        // Print the number of 2s that divide n
        while (n%2==0)
        {
           hs.add((long) 2);
            n /= 2;
        }
        long k= (long) Math.sqrt(n);
        for (int i = 3; i <= k; i+= 2)
        {
            while (n%i == 0)
            {
                hs.add((long) i);
                n /= i;
            }
        }
        if (n > 2)
            hs.add(n);
    }

    public static long bsearchg(int[] a, int t) {
        long ans = 0;
        int low = 0;
        int high = a.length - 1;
        while (low <= high) {
            int mid = (low + high) / 2;
            if (a[mid] <= t) {
                ans = mid;

                low = mid + 1;
            } else
                high = mid - 1;

        }
        return ans;

    }

    private static long fib(long n) {
        if (n == 1) return y;
        if (n == 0) return x;
        long[][] F = new long[][]{{1, -1}, {1, 0}};
        matPow(F, n);
        return F[0][0];
        //return 0l;
    }

    private static void matPow(long[][] F, long n) {
        if (n == 0 || n == 1)
            return;
        long M[][] = new long[][]{{1, -1}, {1, 0}};

        matPow(F, n / 2);
        matrixMult(F, F);

        if (n % 2 != 0)
            matrixMult(F, M);
    }

    public static long MOD(long x,long y)
    {
        long xk=x;
        long yk=y;
        if(xk<0)
        {
           xk+=mod;
        }if(yk<0)
        {
            yk+=mod;
        }
        return (xk+yk)%mod;

    }
    private static void matrixMult(long A[][], long M[][]) {
        long a = MOD((A[0][0] * M[0][0]) %mod, (A[0][1] * M[1][0])%mod) % mod;
        long b = MOD((A[0][0] * M[0][1])%mod , (A[0][1] * M[1][1])%mod) % mod;
        long c = MOD((A[1][0] * M[0][0])%mod, (A[1][1] * M[1][0])%mod) % mod;
        long d = MOD((A[1][0] * M[0][1])%mod, (A[1][1] * M[1][1])%mod)% mod;

        A[0][0] = a;
        A[0][1] = b;
        A[1][0] = c;
        A[1][1] = d;
    }

    private static long lcm(long a, long b) {
        return (long) ((a * b) / euclgcd(a, b));
    }

    public static int[] rotate(int[] order, int by) {
        int length = order.length;
        int[] a = new int[length];
        for (int i = 0; i < length; i++) {
            a[(i + by) % length] = order[i];

        }
        return a;

    }

    public static long modinv(long x, long m) {
        return powmod(x, m - 2, m);

    }

    public static long eulertoitent(long n) {
        long res = n;
        for (int i = 2; i * i <= n; i++)
            if (n % i == 0) {
                while (n % i == 0)
                    n /= i;
                res -= res / i;
            }
        if (n > 1)
            res -= res / n;
        return res;

    }

    //calculate factorial till modulas
    public static void fact() {
        facto[0] = 1;
        for (int i = 1; i <= mod; i++) {
            facto[i] = (i * facto[i - 1]) % mod;
        }

    }

    public static void sieve() {
        arr[0] = 1;
        arr[1] = 1;

        for (int i = 2; i * i < 1000001; i++) {
            if (arr[i] == 0) {

                for (int j = i * i; j < 1000001; j += i) {
                    arr[j] = 1;
                }
            }
        }
        for (int i = 2; i < 1000001; i++) {
            if (arr[i] == 0)
                p.add(i);
        }
    }

    public static boolean isPrime(int n) {
        // Corner cases
        if (n <= 1) return false;
        if (n <= 3) return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0) return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

    public static long euclgcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return euclgcd(b, a % b);

    }

    public static long powmod(long x, long n, long m) {
        long result = 1L;
        while (n > 0) {
            if (n % 2 == 1)
                result = (result * x) % m;
            x = (x * x) % m;
            n = n / 2;
        }

        return result;
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Try
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);

    String m = "31 28 31 30 31 30 31 31 30 31 30 31 ";
    String leap = "31 29 31 30 31 30 31 31 30 31 30 31 ";
    String temp = m + leap + m + m + m + leap + m + m;

    int x = sc.ni();

    String s = sc.nextLine();
    if(temp.contains(s))
        w.println("Yes");
    else
        w.println("No");

      w.close();

    }

     static class Student
    {

        int index;
        int diff;
        Student(int index,int diff)
        {
            this.index = index;
            this.diff = diff;

        }

    }

     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static int primeFactors(int n,int x)
    {
        as = new ArrayList<>();
        int sum = 0;
        // Print the number of 2s that divide n
        while (n%2==0)
        {

            if(sum == x-1)
                break;
            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;
            sum++;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");
                if(sum == x-1)
                break;
                as.add(i);
                n /= i;
                sum++;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {
            sum++;
            as.add(n);
        }
            return sum;
    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

    if(n == 2)
        return true;
    if(n == 3)
        return true;
    if(n % 2 == 0)
        return false;
    if(n % 3 == 0)
        return false;

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static boolean binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;

        while(st <= end)
        {
            int mid = st + (end-st)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else if(p == arr[mid])
            {

            re = true;
            break;
            }

        }
         return re;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package months.years;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Asad Abbas
 */

public class MonthsYears {

   public static class numbers{
       public int  num =0;
       public int index =0;
       public numbers(int num , int index){
           this.num = num;
           this.index = index;
       }
   }
    /**
     * @param args the command line arguments
     */
    public static boolean check(List<Integer> arr , int [] check){
        for (int i = 0; i < arr.size(); i++) {
            if(arr.get(i) != check[i]){
                return false;
            }
        }
        return true;
    }
    public static int getindex(List<numbers> arr , int count , int num){
        int countcheck = 1;
        List<numbers> temp = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            numbers abc = arr.get(i);
            if(abc.num == num){
                temp.add(abc);
            }
        }
        for (int i = 0; i < temp.size(); i++) {
            if(countcheck == count){
                return temp.get(i).index;
            }
            else{
                countcheck++;
            }
        }
        return -1;
    }
    static List<Integer>  getseq(int [] arr , int i , int count){
        List<Integer> arrr = new ArrayList<>();
        while (count-->0) {
            arrr.add(arr[i]);
            i++;
            if(i >= arr.length){
                i=0;
            }
        }
        return arrr;
    }
    public static void main(String[] args) {
        int [] months = new int[]{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,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};
        List<numbers> data = new ArrayList<>();

        for (int i = 0; i < months.length; i++) {
            data.add(new numbers(months[i],i));
        }
        boolean abc = true;
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] arr = new int[n];
        int start = 0;
        while (n-->0) {
            int a = s.nextInt();

            arr[start] = a;
            start++;
        }

       int count = 1;
       boolean flag = true;
        for (int i = 0; i < months.length; i++) {
            int index = getindex(data , count , arr[0]);
            if(index != -1){
                List<Integer> news = getseq(months , index , arr.length);

                if(check(news , arr)){
                    flag = false;
                    System.out.println("Yes");
                    break;
                }
            }
            count++;
        }
        if(flag){
             System.out.println("No");
        }

    }

}

import java.util.*;
public class JavaApplication7 {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          int[] arr = new int[13];
          arr[1]=31;
          arr[2]=28;
          arr[3]=31;
          arr[4]=30;
          arr[5]=31;
          arr[6]=30;
          arr[7]=31;
          arr[8]=31;
          arr[9]=30;
          arr[10]=31;
          arr[11]=30;
          arr[12]=31;
          int n =input.nextInt();
          String answer = "Yes";
          String entry ="";

          int counter =0;
          for(int i=0;i<n;i++)
          {
                 int x =input.nextInt();
                 if (counter!=0)
                 {
                     if(counter%4==0&&counter%100!=0||counter%400==0)
                     {
                         if(x==29||x==28)
                         {
                             x=28;
                                     counter=0;
                         }
                     }

                 }
               if(x==29&&counter==0)
               {
                   x=28;
                   counter++;
               }
                 entry += x+" ";
          }

           String months= arr[1]+" "+arr[2]+" "+arr[3]+" "+arr[4]+" "+arr[5]+" "+arr[6]+" "+arr[7]+" "+arr[8]+" "+arr[9]+" "+arr[10]+" "+arr[11]+" "+arr[12]+" ";
            boolean found = months.contains(entry);

            if(found)System.out.println("Yes");
            else{
                StringBuffer months1=new StringBuffer(months);
                for(int i=1;i<=n;i++)
                    months1.append(months);

               int found1 = months1.indexOf(entry);
                if(found1!=-1)System.out.println("Yes");
                else System.out.println("No");

          }
      }}

import java.util.Scanner;

public class Test5
{
public static void main(String[] args)
{
    String[] mnths = {"31","28","31","30","31","30","31","31","30","31","30","31"};
    int leapStart = -1;
    Scanner sc = new Scanner(System.in);
    int mnCount = Integer.valueOf(sc.nextLine());
    int pos = 0;
    int [] startPos = new int[12];
    String[] splits = sc.nextLine().split(" ");
    for (int i = 0; i < mnCount; i++)
        {
            for (int j = 0; j < 12; j++)
            {
                if (j == 1 && splits[i].equals("29"))
                {
                    if (leapStart > 0)
                    {
                        leapStart = 10;
                        break;
                    }
                    else
                    {
                        leapStart = 1;
                        startPos[(24 + j - i) % 12]++;
                    }
                }
                else if (splits[i].equals(mnths[(j)]) && startPos[(24 + j - i) % 12] >= 0)
                    startPos[(24 + j - i) % 12]++;
                else
                    startPos[(24 + j - i) % 12] = -1;
            }

            if (leapStart == 10)
            {
                System.out.println("No");
                break;
            }
        }
    boolean possible = false;
    if(leapStart!=10){
    for (int i = 0; i < startPos.length; i++)
    {
        if(startPos[i] == mnCount ) {possible = true; break;}
    }
    if(possible) System.out.println("Yes");
    else System.out.println("No");
    }

}
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());

        int[] months = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int[] compare = new int[n];
        int index = 0;
        int leapCount = 0;
        while(n-->0){
            int a = Integer.parseInt(st.nextToken());
            compare[index++] = a == 29 ? 28 : a;
            leapCount += a == 29 ? 1 : 0;
        }

        if(leapCount > 1){
            System.out.println("No");
            return;
        }

        for(int i = 0; i<12; i++){
            if(months[i] != compare[0])
                continue;
            int currMonthIndex = i;
            boolean found = true;
            for(int j = 0; j<compare.length; j++){
                int val = compare[j];
                if(val != months[currMonthIndex])
                    found = false;
                currMonthIndex++;
                currMonthIndex%=months.length;
            }
            if(found){
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");

    }
}

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
      Scanner sc = new Scanner(System.in);
      String e = sc.nextLine();
      String s1 = sc.nextLine();
      sc.close();
      String s = "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 29 31 30 31 30 31 31 30 31 30 31";
      if (s.contains(s1)) {
    	  System.out.println("YES");
      }
      else
    	  System.out.println("NO");
	}
}

import java.io.*;
import java.util.*;
public class B
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String p1="31 28 31 30 31 30 31 31 30 31 30 31";
        String p2="31 29 31 30 31 30 31 31 30 31 30 31";
        String[] a=new String[5];
        a[0]=p1+" "+p1+" "+p1+" "+p1;
        a[1]=p2+" "+p1+" "+p1+" "+p1;
        a[2]=p1+" "+p2+" "+p1+" "+p1;
        a[3]=p1+" "+p1+" "+p2+" "+p1;
        a[4]=p1+" "+p1+" "+p1+" "+p2;

        String in=br.readLine();
        boolean bool=false;
        for(int i=0;i<5 && !bool;i++)
            bool=a[i].indexOf(in)!=-1;
        System.out.println(bool ? "YES" : "NO");
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int[] h = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int[] l = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int[] years = new int[60];
        for (int i = 0; i < 12; i++) {
            years[i] = l[i];
        }
        for (int i = 0; i < 12; i++) {
            years[i + 12] = l[i];
        }
        for (int i = 0; i < 12; i++) {
            years[i + 24] = h[i];
        }
        for (int i = 0; i < 12; i++) {
            years[i + 36] = l[i];
        }
        for (int i = 0; i < 12; i++) {
            years[i + 48] = l[i];
        }

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }

        for (int i = 0; i < 60 - n; i++) {
            boolean found = true;
            for (int j = 0; j < n; j++) {
                found &= years[i + j] == arr[j];
                if (!found) break;
            }
            if (found) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.*;
import java.io.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) throws IOException {
       //Scanner sc = new Scanner(System.in);
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String pp = "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";
       String pp2 = "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 t = Integer.parseInt(br.readLine());
       //StringBuilder str = new StringBuilder();

       String s = br.readLine();
       if(s.length()>pp.length()){
       	 while(s.length()>pp.length()){
            pp += pp2;
            pp += pp;
            pp2 += pp;
            pp2 += pp;
       	 }
       }

      // System.out.println(s);
       Pattern p1 = Pattern.compile(s);
       Matcher m1 = p1.matcher(pp);

       boolean flag = false;

       while(m1.find()){
          System.out.println("Yes");
          flag = true;
          break;
       }

       if(!flag){
       	 Pattern p2 = Pattern.compile(s);
         Matcher m2 = p2.matcher(pp2);

         while(m2.find()){
            System.out.println("Yes");
            flag = true;
            break;
         }
       }

       if(!flag){
       	  System.out.println("No");
       }

	}
}

import java.io.*;
public class aks
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String s=br.readLine();
        String l=" 31 29 31 30 31 30 31 31 30 31 30 31";
        String n1=" 31 28 31 30 31 30 31 31 30 31 30 31";
        String c1=l+n1+n1;
        String c2=n1+l+n1;
        String c3=n1+n1+l;
        String c4=n1+n1+n1;
        if(c1.contains(s)||c2.contains(s)||c3.contains(s)||c4.contains(s))
        System.out.println("YES");
        else
        System.out.println("NO");

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class codforecesdiv2 {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int t = fr.nextInt();
        String s=new String();
        String s1="";
        String s2="312831303130313130313031312831303130313130313031312831303130313130313031";
        String s3="312831303130313130313031312831303130313130313031312931303130313130313031312831303130313130313031312831303130313130313031";
        for (int i=0;i<t;i++){
        	s=fr.next();
        	s1=s1+s;
        }
        int counter=0;
        if (s2.contains(s1)){
        	counter++;
        }
        else if(s3.contains(s1)){
        	counter++;
        }
        if (counter>0){
        	System.out.println("YES");
        }
        else{
        	System.out.println("NO");
        }
    }
}

import java.io.*;
import java.util.*;

public class Solving{

    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        String l = "31-29-31-30-31-30-31-31-30-31-30-31-";
        String e = "31-28-31-30-31-30-31-31-30-31-30-31-";

        String c="";
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            c+=sc.next()+"-";

        }
        String c1=l+e+e;
        String c2=e+l+e;
        String c3=e+e+l;
        if(c1.contains(c) || c2.contains(c)|| c3.contains(c))System.out.println("Yes");
        else System.out.println("No");

    }
  //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class year {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        String y="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 31 29 31 30 31 30 31 31 30 31 30 31";
        int n=Integer.parseInt(bf.readLine());
        String t=bf.readLine(),flag="NO";
        if (y.contains(t)) {
            flag="YES";
        }
        out.write(flag+"\n");
        out.flush();
    }
}

import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

import java.util.InputMismatchException;

public class B_452 {
public static void main(String[] args){
 InputReader in=new InputReader(System.in);
 PrintWriter pw=new PrintWriter(System.out);
 int n=in.readInt();
 String s1="312831303130313130313031";
 String s2="312931303130313130313031";
 String s3= s1+ s1+ s2 + s1 +s1;
 String s="";
 for(int i=0;i<n;i++){
	String inp=in.readString();
	s=s+inp;
 }

 if(s3.contains(s)) {
	 pw.println("Yes");
 }
 else {
	 pw.println("No");
 }
 pw.close();
}
static long fib(long n)
{
long F[][] = new long[][]{{1,1},{1,0}};
if (n == 0)
    return 0;
power(F, n-1);

   return F[0][0];
}

 /* Helper function that multiplies 2 matrices F and M of size 2*2, and
 puts the multiplication result back to F[][] */
static void multiply(long F[][], long M[][])
{
long x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];
long y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
long z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];
long w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];

F[0][0] = x%1000000007;
F[0][1] = y%1000000007;
F[1][0] = z%1000000007;
F[1][1] = w%1000000007;
}

static void power(long F[][], long n)
{
long i;
long M[][] = new long[][]{{1,1},{1,0}};

// n - 1 times multiply the matrix to {{1,0},{0,1}}
for (i = 2; i <= n; i++)
    multiply(F, M);
}
static long modulo(long a,long b,long c) {
	long x=1;
	long y=a;
	while(b > 0){
		if(b%2 == 1){
			x=(x*y)%c;
		}
		y = (y*y)%c; // squaring the base
		b /= 2;
	}
	return  x%c;
}
static long gcd(long x, long y)
{
	if(x==0)
		return y;
	if(y==0)
		return x;
	long r=0, a, b;
	a = (x > y) ? x : y; // a is greater number
	b = (x < y) ? x : y; // b is smaller number
	r = b;
	while(a % b != 0)
	{
		r = a % b;
		a = b;
		b = r;
	}
	return r;
}
static class Pair implements Comparable<Pair>{
	int x,y;
	Pair(int xx,int yy){
		x=xx;y=yy;
	}
	@Override
	public int compareTo(Pair o) {
		if(Integer.compare(o.y, this.y)==0){
			return Integer.compare(this.x, o.x);
		}
		else{
			return Integer.compare(this.y, o.y);
		}
	}
}
static  class InputReader
{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    public String readLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }
    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next()
    {
        return readString();
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }
}
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class MonthYear implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }

	// if modulo is required set value accordingly
	public static long[][] matrixMultiply2dL(long t[][],long m[][])
	{
		long res[][]= new long[t.length][m[0].length];

		for(int i=0;i<t.length;i++)
		{
			for(int j=0;j<m[0].length;j++)
			{
				res[i][j]=0;
				for(int k=0;k<t[0].length;k++)
				{
					res[i][j]+=t[i][k]+m[k][j];
				}
			}
		}

		return res;
	}

	static long combination(long n,long r)
	{
		long ans=1;
		for(long i=0;i<r;i++)
		{
			ans=(ans*(n-i))/(i+1);
		}
		return ans;
	}

    public static void main(String args[]) throws Exception
    {
        new Thread(null, new MonthYear(),"MonthYear",1<<27).start();
    }
	// **just change the name of class from Main to reuquired**
    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);

		int y1[]={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 y2[]={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 n=sc.nextInt();
		int a[]= new int[n];
		for(int i=0;i<n;++i) a[i]=sc.nextInt();

		boolean isPossible=false;
		for(int i=0;i<y1.length;++i)
		{
			boolean f=true;
			for(int j=0;j<n;++j)
			{
				if(a[j]!=y1[(i+j)%24])
				{
					f=false;
					break;
				}
			}

			if(f)
			{
				isPossible=true;
				break;
			}
		}

		if(isPossible) w.println("YES");
		else
		{
			for(int i=0;i<y2.length;++i)
			{
				boolean f=true;
				for(int j=0;j<n;++j)
				{
					if(a[j]!=y2[(i+j)%24])
					{
						f=false;
						break;
					}
				}

				if(f)
				{
					isPossible=true;
					break;
				}
			}

			if(isPossible) w.println("YES");
			else w.println("NO");
		}

        System.out.flush();
        w.close();
    }
}

import java.io.*;

public class MonthsAndYears
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String data = "31 28 31 30 31 30 31 31 30 31 30 31";
		String data1 = "31 29 31 30 31 30 31 31 30 31 30 31";
		int n = Integer.parseInt(in.readLine());
		String input = in.readLine().trim();
		String a = data+" "+data+" "+data+" "+data1+" "+data+" "+data+" "+data;
		if(a.contains(input))
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}

	}
}

import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String calendar="31 28 31 30 31 30 31 31 30 31 30 31";
        String calendarl="31 29 31 30 31 30 31 31 30 31 30 31";
        calendar+=" "+calendar+" "+calendar+" "+calendarl;
        calendar+=" "+calendar;
        int n=in.nextInt();
        int [] tmp=new int[n];
        for(int i=0;i<n;++i)
            tmp[i]=in.nextInt();
        String index="";
        for(int i=0;i<tmp.length;++i){
            index+=tmp[i];
            if(i!=tmp.length-1)
                index+=" ";
        }

        if(calendar.indexOf(index)!=-1 )
            System.out.println("YES");
        else
            System.out.println("NO");
    }

}

import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		boolean fair = true;
		boolean leaped = false;
		boolean thirty1 = false;
		boolean thirty = false;
		boolean twenties = false;

		for(int i = 0; i < n; i++){
			shiva[i] = input.nextInt();
			if(shiva[i] == 28 ){
				twenties = true;
			}else if(shiva[i] == 29 ){
				twenties = true;
			}else if(shiva[i] == 30 ){
				thirty = true;
			}else if(shiva[i] == 31){
				thirty1 = true;
			}
		}

		for(int i = 0; i < n-1; i++){

			if(shiva[i] == 28 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 29 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 30 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 31){
				if(i != 0 && shiva[i-1] == 31 && shiva[i+1] == 31){
					fair = false;
				}

				if(i != 0 && shiva[i-1] != 31){ // precondition fix for before and after feb, find howmany months there are
					if(shiva[i+1] == 28 || shiva[i+1] == 29)
						fair = false;
				}

				if(i == 0 && shiva[i+1] != 31 && shiva[i+1] != 30 && shiva[i+1] != 29 && shiva[i+1] != 28)
					fair = false;
			}
			if(thirty1 == false || thirty == false || twenties == false){
				if(i >= 10){
					fair = false;}
			}
			if(leaped == true && shiva[i] == 29)
				fair = false;

			if(shiva[i] == 29){
				leaped = true;
			}
		}

		if(fair == false){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}

	}
}

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        Solver s = new Solver();
        int test = 1;
        for (int i = 1; i <= test; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {

    int[] m = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    void solve(int test_case, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        if (check(a)) {
            out.println("Yes");
            return;
        }
        out.println("No");
    }

    private boolean check(int[] a) {
        for (int j = 0; j < 12; j++) {
            boolean ok = true, is29 = false;
            for (int i = 0, k = j; i < a.length; i++, k++) {
                k %= 12;
                if (a[i] == m[k]) continue;
                if (m[k] == 28) {
                    if (a[i] == 29) {
                        if (is29) {
                            ok = false;
                        } else {
                            is29 = true;
                        }
                        continue;
                    }
                }
                ok = false;
            }
            if (ok) return true;
        }
        return false;
    }

    static class IntList {
        private int initialCapacity;
        private int[] array;
        private int used = 0;
        private final int MAX = (int) 1e2;

        /**
         * Creates a new instance of IntMap
         */
        IntList() {
            initialCapacity = MAX;
            array = allocArray(initialCapacity);
        }

        /**
         * Add an integer to the lineStartList.  Must be greater than the preceding value
         * or an exception is thrown.
         */
        public synchronized void add(int value) {
            if (used >= array.length) {
                growArray();
            }
            array[used++] = value;
        }

        private int[] allocArray(int size) {
            int[] result = new int[size];
            //Fill it with Integer.MAX_VALUE so binarySearch works properly (must
            //be sorted, cannot have 0's after the actual data
            Arrays.fill(result, Integer.MAX_VALUE);
            return result;
        }

        public synchronized int get(int index) {
            if (index >= used) {
                throw new ArrayIndexOutOfBoundsException("List contains " + used
                        + " items, but tried to fetch item " + index);
            }
            return array[index];
        }

        public boolean contains(int val) {
            return Arrays.binarySearch(array, val) >= 0;
        }

        public void sort() {
            Arrays.sort(array, 0, used);
        }

        public int lower_bound(int val) {
            int low = 0, high = used - 1;
            while (low <= high) {
                int mid = low + high >> 1;
                if (get(mid) >= val && (mid == 0 || get(mid - 1) < val)) return mid;
                if (get(mid) >= val) {
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }
            return used;
        }

        public int upper_bound(int val) {
            int low = 0, high = used - 1;
            while (low <= high) {
                int mid = low + high >> 1;
                if (get(mid) > val && (mid == 0 || get(mid - 1) <= val)) return mid;
                if (get(mid) > val) {
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }
            return used;
        }

        /**
         * Return the index of the value closest to but lower than
         * the passed value
         */
        public int findNearest(int val) {
            if (size() == 0) {
                return -1;
            }
            return findInRange(val, 0, size());
        }

        /**
         * Recursive binary search
         */
        private int findInRange(int val, int start, int end) {
            if (end - start <= 1) {
                return start;
            }
            int midPoint = start + ((end - start) / 2);
            int valAtMidpoint = get(midPoint);
            if (valAtMidpoint > val) {
                return findInRange(val, start, start + ((end - start) / 2));
            } else {
                return findInRange(val, start + ((end - start) / 2), end);
            }
        }

        public int indexOf(int val) {
            int result = Arrays.binarySearch(array, val);
            if (result < 0) {
                result = -1;
            }
            if (result >= used) {
                result = -1;
            }
            return result;
        }

        public synchronized int size() {
            return used;
        }

        private void growArray() {
            int[] old = array;
            array = allocArray(Math.round(array.length * 1.5f));
            System.arraycopy(old, 0, array, 0, old.length);
        }

        public String toString() {
            StringBuffer result = new StringBuffer("IntList [");
            for (int i = 0; i < used; i++) {
                result.append(i);
                result.append(':');
                result.append(array[i]);
                if (i != used - 1) {
                    result.append(',');
                }
            }
            result.append(']');
            return result.toString();
        }

    }
}

class InputReader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public InputReader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public InputReader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String nextLine() throws IOException {
        byte[] buf = new byte[(int) 1e7]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.') {
            while ((c = read()) >= '0' && c <= '9') {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null)
            return;
        din.close();
    }

    public String next() throws IOException {
        byte[] buf = new byte[(int) 1e7]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n' || c == ' ')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.stream.Collectors;

public class CFB {
    private static final long MOD = 1_000_000_007L;
    private static final long LIMIT = 1L << 60; //10^18

    static FastScanner sc;
    static int[] as;
    static int[] months1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    static int[] months2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public static void main(String[] args) {
        sc = new FastScanner(System.in);

        int n = sc.nextInt();
        as = readIntArray(n);
//        Map<Integer, Integer> map = Arrays.stream(as).boxed().collect(Collectors.toMap(i -> i, i -> 1, (a, b) -> a + 1));

        int[] months = new int[12*5];
        System.arraycopy(months1, 0, months, 0, 12);
        System.arraycopy(months1, 0, months, 12, 12);
        System.arraycopy(months2, 0, months, 24, 12);
        System.arraycopy(months1, 0, months, 36, 12);
        System.arraycopy(months1, 0, months, 48, 12);

        for (int i = 0; i < 60-n; i++) {
            boolean yes = true;
            for (int j = i; j < i+ n; j++) {
                if (as[j-i] != months[j]) {
                    yes = false;
                    break;
                }
            }

            if (yes) {
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");
    }

    //********************************************************************************************
    //********************************************************************************************
    //********************************************************************************************

    private static int ceil(double d) {
        int ret = (int) d;
        return ret == d ? ret : ret + 1;
    }

    private static int round(double d) {
        return (int) (d + 0.5);
    }

    @SuppressWarnings("SameParameterValue")
    private static <T> T elvis(T obj, T defValue) {
        return obj == null ? defValue : obj;
    }

    private static int gcd(int a, int b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    private static int[] readIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextInt();
        }
        return res;
    }

    private static long[] readLongArray(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextLong();
        }
        return res;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}

import java.io.*;
import java.util.*;
import java.util.regex.*;
public class vk18
{
    public static void main(String[]stp) throws Exception
    {
    	Scanner scan=new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //String []s;
        String n=br.readLine();
        //for(i=0;i<n;i++) {k=scan.nextInt(); na+=""+k+" "; }
        String na=br.readLine();
        //System.out.println(na);
        String no="31 28 31 30 31 30 31 31 30 31 30 31";
        String leap="31 29 31 30 31 30 31 31 30 31 30 31";
        String mix=no+" "+leap+" "+no+" "+no+" "+no+" "+no+" "+leap+" "+no;
        //System.out.println(mix);
        if(mix.contains(na)) {System.out.println("YES");  }
        else System.out.println("NO");

    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = readInt();
        int[] a = readIntArray(n);
        int[] arr = {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,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        n = arr.length;
        boolean flag;
        for (int i = 0; i < n - a.length; i++) {
            flag = true;
            for (int j = 0; j < a.length; j++) {
                if (arr[i + j] != a[j]) flag = false;
            }
            if (flag) {
                out.println("Yes");
                return;
            }
        }
        out.println("No");

    }

    int checkBit(int mask, int bit) {
        return (mask >> bit) & 1;
    }

    public static void main(String[] args) throws IOException {

        new Main().run();
    }

    boolean isLower(char a) {
        return ((int) a) >= 97 ? true : false;
    }

    int INF = Integer.MAX_VALUE / 10;

    int[][] STEPS = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    Random rnd = new Random();
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    Main() throws FileNotFoundException {

        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        tok = new StringTokenizer("");
    }

    long checkBit(long mask, int bit) {
        return (mask >> bit) & 1;
    }

    void run() throws IOException {
        solve();
        out.close();
    }

    char varChar;
    int varInt, varInt1, varInt2;
    long varLong;

    long sqrt(long m) {
        long l = 0;
        long r = m;
        long answer = 0;
        long mid = 0;
        while (l <= r) {
            mid = (l + r) / 2;
            if (mid * mid <= m) {
                answer = mid;
                l = mid + 1;
            } else r = mid - 1;
        }
        return answer;
    }

    int countPow(int m, int n) {
        varInt = 0;
        while (m % n == 0 && m > 0) {
            varInt++;
            m /= n;
        }
        return varInt;
    }

    long binPow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return a * binPow(a, b - 1);
        } else {
            varLong = binPow(a, b / 2);
            return varLong * varLong;
        }

    }

    int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    long pow(long x, long k) {
        varLong = 1;
        for (int i = 0; i < k; ++i) {
            varLong *= x;
        }
        return varLong;
    }

    class Fenwik {
        private long[] t;
        private int length;

        Fenwik(int[] a) {
            this.length = a.length + 100;
            this.t = new long[length];
            for (int i = 0; i < a.length; ++i) {
                this.inc(i, a[i]);
            }
        }

        void inc(int i, int delta) {
            for (; i < this.length; i = i | (i + 1)) {
                this.t[i] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;

            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += this.t[r];
            }

            return sum;
        }

    }

    // ////////////////////////////////////////////////////////////////////

    String delimiter = " ";

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine)
                return null;

            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken(delimiter);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int b) {
        int a[] = new int[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = readInt();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }

    int[] readSortedIntArray(int size) throws IOException {
        Integer[] array = new Integer[size];

        for (int index = 0; index < size; ++index) {
            array[index] = readInt();
        }
        Arrays.sort(array);

        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) {
            sortedArray[index] = array[index];
        }

        return sortedArray;
    }

    int[] sortedIntArray(int size, int[] array) throws IOException {
        for (int index = 0; index < size; ++index) {
            array[index] = readInt();
        }
        Arrays.sort(array);

        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) {
            sortedArray[index] = array[index];
        }

        return sortedArray;
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    long minLong(long... values) {
        long min = Long.MAX_VALUE;
        for (long value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    long maxLong(long... values) {
        long max = Long.MIN_VALUE;
        for (long value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    boolean checkIndex(int index, int size) {
        return (0 <= index && index < size);
    }

    int abs(int a) {
        return Math.abs(a);
    }
}

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {

	public static int[] not_leap_months = {
		//   2,      4,      6,          9,     11
		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,
	};
	public static int[] fst_leap_months = {
		//   2,      4,      6,          9,     11
		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,
	};
	public static int[] snd_leap_months = {
		//   2,      4,      6,          9,     11
		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,
	};
	public static int[] thd_leap_months = {
		//   2,      4,      6,          9,     11
		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,
	};

	public static boolean match(int[] m, int[] months){
		LOOP:
		for(int start = 0; start <= (months.length - m.length); start++){
			for(int i = 0; i < m.length; i++){
				if(m[i] != months[start + i]){ continue LOOP; }
			}

			return true;
		}

		return false;
	}

	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			final int n = sc.nextInt();

			int[] month = new int[n];
			for(int i = 0; i < n; i++){ month[i] = sc.nextInt(); }

			if(match(month, not_leap_months)){
				System.out.println("YES");
			}else if(match(month, fst_leap_months)){
				System.out.println("YES");
			}else if(match(month, snd_leap_months)){
				System.out.println("YES");
			}else if(match(month, thd_leap_months)){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {
					tok = new StringTokenizer(br.readLine());
				}
			} catch (IOException e) { /* ignore */
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public void close() {
			try {
				br.close();
			} catch (IOException e) { /* ignore */
			}
		}
	}
}

import java.util.Scanner;

public class MonthsAndYears {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();scan.nextLine();
		String s=scan.nextLine();
		String normal="31 28 31 30 31 30 31 31 30 31 30 31 ";
		String leap="31 29 31 30 31 30 31 31 30 31 30 31 ";
		String key=normal+leap+normal+normal+normal+leap+normal+normal;
//		System.out.println(key);
		System.out.println(key.contains(s)?"YES":"NO");
	}
}

//package kanak;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Solution{
    public  static  void main(String [] args){
        InputReader fi=new InputReader(System.in);
        int [] leap={31,   29,31,30,31,30,31,31,30,31,30,31};
        int [] nonleap={31,28,31,30,31,30,31,31,30,31,30,31};
        boolean ans=false;
        int n=fi.nextInt();
        int i,j,k;
        int a[]=new int[n];
        for (i=0;i<n;i++)
            a[i]=fi.nextInt();
        boolean lp=false;
        boolean nlp=false;
        boolean lp2=false;
        boolean nlp2=false;
            for (i=0;i<12;i++){
                for (j=0,k=i;j<Math.min(12,n);j++,k++){
                    if (leap[k%12] == a[j])
                        continue;

                    else
                        break;

                }
                if (j==Math.min(12,n)) {
                    lp=true;
                }
            }

            for (i=0;i<12 ;i++){
                for (j=0,k=i;j<Math.min(12,n);j++,k++){
                    if (nonleap[k%12] == a[j])
                        continue;
                    else
                        break;
                }
                if (j==Math.min(12,n)) {
                    nlp=true;
                }
            }

            if (n < 12){
                if (lp || nlp)
                    ans=true;
            }

            else {

                    for (i = 0; i < 12; i++) {
                        for (j = 12, k = i; j < n; j++, k++) {
                            if (leap[k % 12] == a[j])
                                continue;

                            else
                                break;

                        }
                        if (j == n) {
                            lp2 = true;
                        }
                    }

                for (i=0;i<12 ;i++){
                    for (j=12,k=i;j<n;j++,k++){
                        if (nonleap[k%12] == a[j])
                            continue;
                        else
                            break;
                    }
                    if (j==n) {
                        nlp2=true;
                    }
                }

                if (lp && nlp2 || (nlp && lp2) ||  (nlp && nlp2)){
                        ans=true;
                }

            }

           // System.out.println(" lp " +lp + " nlp " +nlp + " lp2 " +lp2 + " nlp2 " +nlp2);
        if (ans)
        {
            System.out.println("Yes");
        }
        else
            System.out.println("No");

    }

}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.Scanner;

public class MonthsAndYears {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int numberOfInteger = scanner.nextInt();
        scanner.nextLine();
        String monthDays = scanner.nextLine();

        String daysNumberFrScannerWithoutSpaces = monthDays.trim().replace(" ", "");

        String notLeapYearDays = "31 28 31 30 31 30 31 31 30 31 30 31";
        String leapYearDays = "31 29 31 30 31 30 31 31 30 31 30 31";

        StringBuilder daysForFourYearWithLeapYearBuilder = new StringBuilder();
        String daysForSixYearsWithLeapYearInTheMiddle = daysForFourYearWithLeapYearBuilder
                .append(notLeapYearDays)
                .append(notLeapYearDays)
                .append(leapYearDays)
                .append(notLeapYearDays)
                .append(notLeapYearDays)
                .append(notLeapYearDays)
                .toString()
                .replace(" ", "");

        if(daysForSixYearsWithLeapYearInTheMiddle.contains(daysNumberFrScannerWithoutSpaces)){
            System.out.println("YES");
        } else
            System.out.println("NO");

    }

}

import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class SPOJANDCC
{
	@SuppressWarnings("rawtypes")
	static InputReader in;
	static PrintWriter out;

	static void solve()
	{
		int arr[] = new int[200 * 12];
		arr[0] = 31;
		arr[1] = 28;
		arr[2] = 31;
		arr[3] = 30;
		arr[4] = 31;
		arr[5] = 30;
		arr[6] = 31;
		arr[7] = 31;
		arr[8] = 30;
		arr[9] = 31;
		arr[10] = 30;
		arr[11] = 31;
		for (int i = 12; i < 24; i++)
			arr[i] = arr[i - 12];
		arr[13]++;
		for (int i = 24; i < 48; i++)
			arr[i] = arr[i - 24];
		arr[37]--;
		for (int i = 48; i < 48 + 24; i++)
			arr[i] = arr[i - 24];
		for (int i = 12; i < 48 + 24; i++)
		{
			arr[i + 48 + 24 - 12] = arr[i];
		}
		int n = in.ni();
		int a[] = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.ni();
		for (int i = 0; i < 100; i++)
		{
			boolean u = true;
			for (int j = i; j < i + n; j++)
			{
				if (arr[j] != a[j - i])
				{
					u = false;
					break;
				}
			}
			if (u)
			{
				out.println("Yes");
				return;
			}
		}
		out.println("No");
	}

	@SuppressWarnings("rawtypes")
	static void soln()
	{
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args)
	{
		new Thread(null, new Runnable()
		{
			public void run()
			{
				try
				{
					soln();
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	static class InputReader<SpaceCharFilter>
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = ni();
			}
			return a;
		}

		public long[] nextLongArray(int n)
		{
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nl();
			}
			return a;
		}

		public String readString()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}

	}
}

import java.util.Scanner;

public class Main {

    public static boolean special(int d) {
        if(d == 28 || d == 29)
            return true;
        return false;
    }

	public static void main (String[] args) {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int[] ar = new int[n];

		for(int i=0; i<n; i++) {
		    ar[i] = in.nextInt();
		}

		boolean ans = false;
		boolean spec = false;

		for(int i=0; i<12; i++) {

		    boolean temp = true;

		    for(int j=0; j<n; j++) {
		        if( special(days[(i+j)%12]) && special(ar[j]) ) {
		            if(ar[j]==29) {
		                if(!spec)
		                    spec = true;
    		            else
    		                temp = false;
		            }
		        }
		        else if( days[(i+j)%12] != ar[j] )
		            temp = false;
		    }

		    if(temp == true) {
		        ans = true;
		        break;
		    }

		}

		if(ans)
		    System.out.println("Yes");
		else
		    System.out.println("No");

	}
}

import java.util.*;
import java.io.IOException;

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int[] days = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    void start() {
        int n = readInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) d[i] = readInt();
        boolean found = false;
        for (int lp0 = 0; lp0 <= 1; lp0++)
            for (int lp1 = 0; lp1 <= 1; lp1++) {
                if (lp0 + lp1 > 1) continue;
                loop:
                for (int i = 0; i < 12; i++) {
                    boolean meet2 = false;
                    for (int j = 0; j < n; j++) {
                        int t = (i + j) % 12;
                        int td = days[t];
                        if (t == 1) {
                            if (!meet2) {
                                td += lp0;
                                meet2 = true;
                            } else {
                                td += lp1;
                            }
                        }
                        if (d[j] != td) continue loop;
                    }
                    found = true;
                    System.out.println("YES");
                    return;
                }
            }
        System.out.println("NO");
    }

    public static void main(String[] args) {
        new Test().start();

    }
}

import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int [] a = {31,28,31,30,31,30,31,31,30,31,30,31};
		int [] b = {31,29,31,30,31,30,31,31,30,31,30,31};

		int n = sc.nextInt();
		int [] arr = new int[n];
		for (int i =0;i<n;i++)
		{
			arr[i] = sc.nextInt();
		}

		int [] temp = new int[36];

		boolean truth = false;

		for (int i =0;i<12;i++)
			temp[i] = a[i];
		for (int i =12;i<24;i++)
			temp[i] = a[i-12];
		for (int i =24;i<36;i++)
			temp[i] = a[i-24];

		 truth = check(arr,temp);

		 if (truth)
			 System.out.println("YES");
		 else
		 {
			 for (int i =0;i<12;i++)
				temp[i] = a[i];
			 for (int i =12;i<24;i++)
				temp[i] = b[i-12];
			 for (int i =24;i<36;i++)
				temp[i] = a[i-24];

			 truth = check(arr,temp);

			 if (truth)
				 System.out.println("YES");
			 else
			 {
				 for (int i =0;i<12;i++)
						temp[i] = b[i];
					 for (int i =12;i<24;i++)
						temp[i] = a[i-12];
					 for (int i =24;i<36;i++)
						temp[i] = a[i-24];

					 truth = check(arr,temp);

					 if (truth)
						 System.out.println("YES");
					 else
					 {
						 for (int i =0;i<12;i++)
								temp[i] = a[i];
							 for (int i =12;i<24;i++)
								temp[i] = a[i-12];
							 for (int i =24;i<36;i++)
								temp[i] = b[i-24];

							 truth = check(arr,temp);

							 if (truth)
								 System.out.println("YES");
							 else System.out.println("NO");
					 }

			 }

		 }

		sc.close();
	}

	public static boolean check(int [] arr, int [] t)
	{
		boolean flag = true;
		for (int i =0;i<36-arr.length;i++)
		{

			if (t[i]==arr[0])
			{
				for (int j = 1;j<arr.length;j++)
				{
					//System.out.println(arr[j]+" "+t[i+j]);
					if (arr[j]!=t[i+j])
					{
						flag=false;
						break;
					}
				}
				//System.out.println(flag);
				if (flag)
					return true;
				flag=true;
			}

		}
		return false;
	}

}

/**
 *
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author rachnkum
 *
 */
public class MonthsAndYears {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        String preMonths = "181010110101181010110101191010110101181010110101181010110101";
        String[] months = br.readLine().split(" ");
        String str="";

        for (int i = 0; i < months.length; i++) {

            int n = Integer.parseInt(months[i]);
            str+=Integer.toString((n%10));
        }
        if(preMonths.contains(str)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

}

import java.util.*;

public class Cc {
   public static void main(String[] args) {
	   Scanner input=new Scanner(System.in);
	   	   int n=input.nextInt();
	   	   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,29,31,30,31,30,31,31,30,31,30,31};
	   	   int []x=new int[n];
	   	   for(int i=0;i<n;i++)
	   		      x[i]=input.nextInt();
	   	   boolean canHappen=false;
	   	   for(int i=0;i<m.length&&!canHappen;i++)
	   	   {
	   		   canHappen=true;
	   		   for(int j=0;j<x.length&&canHappen;j++)
	   			   if(x[j]!=m[(i+j)%m.length])
	   				   canHappen=false;
	   	   }
	   	   if(canHappen)
	   		   System.out.println("YES");
	   	   else
	   		   System.out.println("No");
       }
   }

//no
//package cf452;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class TaskB {

    static class FastScanner {

        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner() {
            this(System.in);
        }

        public FastScanner(InputStream is) {
            mIs = is;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;

        }

    }
    static int fun(int[] months,int[] a){
        for(int i=0;i<a.length;i++) {
            int j=0;
            for(;j<months.length;j++){
                if(months[j]==a[i]){
                    break;
                }
            }
            if(j==months.length) {
                return 0;
            }
        }
        return 1;
    }
    static boolean isSubset(int arr1[], int arr2[]) {
        for(int i=0;i<=arr1.length-arr2.length;i++){
            if(arr1[i]==arr2[0]) {
                int k = 1,j=0;
                for ( j = 1; j < arr2.length; j++) {
                    if (arr1[i + k] == arr2[j]) {
                        k++;
                        continue;
                    } else {
                        break;
                    }
                }
                if( j == arr2.length){
                    return true;
                }
            }
        }
        return false;
    }

    public static void main(String args[])
    {
        FastScanner sc=new FastScanner();
        int arr1[] = {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 arr4[] = {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 arr5[] = {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 arr6[] ={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 p=sc.nextInt();
        int arr2[] = new int[p];
        for(int i=0;i<p;i++){
            arr2[i]=sc.nextInt();
        }
        if(isSubset(arr1, arr2) || isSubset(arr6,arr2)|| isSubset(arr4, arr2) || isSubset(arr5, arr2))
            System.out.print("Yes");
        else
            System.out.print("No");
    }

  /*  public static void main(String args[]){
        FastScanner sc=new FastScanner();
        int[] months={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 n=sc.nextInt();
       int[] a=new int[n];
       for(int i=0;i<n;i++){
           a[i]=(sc.nextInt());
       }
        if(fun(months,a)==1){
           System.out.println("Yes");
        }
        else{
           System.out.println("No");
        }
    }*/
}

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		int N = input.nextInt();

		int[] sequence = {
						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};

		Queue<Integer> pq = new LinkedList<Integer>();

		for (int i = 0; i < N; i++) {
			int num = input.nextInt();
			if (i == 0) {
				for (int state = 0; state < sequence.length; state++)
					if (sequence[state] == num)
						pq.add(state);
			} else {
				LinkedList<Integer> next = new LinkedList<>();
				while (!pq.isEmpty()) {
					int state = pq.poll();
					if (state == sequence.length - 1) continue;
					if (sequence[state + 1] == num)
						next.add(state + 1);
				}
				pq.addAll(next);
			}
		}

		if (pq.isEmpty())
			System.out.println("NO");
		else
			System.out.println("YES");
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        MyScanner in = new MyScanner();
        int n = in.nextInt();
        String low = "312831303130313130313031";
        String high = "312931303130313130313031";
        String range = low + low + high + low + low;

        String pattern = "";
        for (int i = 0; i < n; i++) {
            pattern += in.nextInt();
        }

        System.out.println(range.contains(pattern) ? "Yes": "No");

    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.*;

public class Main {

    public static boolean findLen(int[] arr,int[] podp){
        if (podp.length>arr.length) return false;
        boolean flag = false;
        for (int i = 0; i < arr.length - podp.length + 1; i++) {
            flag=true;
            for (int j = 0; j < podp.length; j++) {
                if (arr[j+i]!=podp[j]){
                    flag=false;
                    break;
                }
            }
            if (flag){
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[]arr = new int[n];
        int help;
        int[] month = new int[]{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};
        for (int i = 0; i < n; i++) {
            arr[i]=scanner.nextInt();
        }
        if (findLen(month,arr)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		// Scanner reader = new Scanner(System.in);
		InputReader reader = new InputReader();
		int n = reader.nextInt();
		StringBuilder check = new StringBuilder();
		String a = "312831303130313130313031312831303130313130313031312831303130313130313031";
		//String b = "312931303130313130313031312931303130313130313031312931303130313130313031";
		String c = "312931303130313130313031312831303130313130313031312931303130313130313031";
		String d = "312831303130313130313031312931303130313130313031312831303130313130313031";
		// 312831303130313130313031
		// 31 28 31 30 31 30 31 31 30 31 30 31
		for (int i = 0; i < n; i++) {
			check.append(reader.next());
		}
		if (a.contains(check) || c.contains(check) || d.contains(check)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}

class InputReader {
	BufferedReader buf;
	StringTokenizer tok;

	InputReader() {
		buf = new BufferedReader(new InputStreamReader(System.in));
	}

	boolean hasNext() {
		while (tok == null || !tok.hasMoreElements()) {
			try {
				tok = new StringTokenizer(buf.readLine());
			} catch (Exception e) {
				return false;
			}
		}
		return true;
	}

	String next() {
		if (hasNext())
			return tok.nextToken();
		return null;
	}

	char nextChar() {
		return next().charAt(0);
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	/*
	 * BigInteger nextBigInteger() { return new BigInteger(next()); }
	 *
	 * BigDecimal nextBigDecimal() { return new BigDecimal(next()); }
	 */
}

import java.io.*;
import java.util.*;
public class B
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String p1="31 28 31 30 31 30 31 31 30 31 30 31";
        String p2="31 29 31 30 31 30 31 31 30 31 30 31";
        String[] a=new String[5];
        a[0]=p1+" "+p1+" "+p1+" "+p1;
        a[1]=p2+" "+p1+" "+p1+" "+p1;
        a[2]=p1+" "+p2+" "+p1+" "+p1;
        a[3]=p1+" "+p1+" "+p2+" "+p1;
        a[4]=p1+" "+p1+" "+p1+" "+p2;

        String in=br.readLine();
        boolean bool=false;
        for(int i=0;i<5 && !bool;i++)
            bool=a[i].indexOf(in)!=-1;
        System.out.println(bool ? "YES" : "NO");
    }
}

import java.util.*;

public class _899B_MonthsAndYears {
    static HashMap<Integer, Integer> _30_31, _31_30, _31_31;
    static Set<Integer> possible;
    static {
        _30_31 = new HashMap<>();
        _30_31.put(3, 4);
        _30_31.put(5, 6);
        _30_31.put(8, 9);
        _30_31.put(10, 11);
        _31_30 = new HashMap<>();
        _31_30.put(2, 3);
        _31_30.put(4, 5);
        _31_30.put(7, 8);
        _31_30.put(9, 10);
        _31_31 = new HashMap<>();
        _31_31.put(6, 7);
        _31_31.put(11, 0);
        possible = new HashSet<>();
    }
    static void check(HashMap<Integer,Integer> map){
        Set<Integer> r=new HashSet<>();
        for (Integer i:possible){
            if(map.containsKey(i)){
                r.add(map.get(i));
            }
        }
        possible = r;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), tmp, old = sc.nextInt();
        boolean leap = false, c = true;
        switch (old){
            case 31:possible.addAll(Arrays.asList(0,2,4,6,7,9,11));break;
            case 30:possible.addAll(Arrays.asList(3,5,8,10));break;
            case 29:leap=true;
            case 28:possible.add(1);break;
        }
        while (n > 1) {
            tmp = sc.nextInt();
            if (c) {
                if (old == 30 && tmp <= 30  || old<=30 && tmp==30 ) {
                    c = false;
                } else if (old == 30 && tmp == 31) {
                    check(_30_31);
                } else if (old==31 && tmp == 30){
                    check(_31_30);
                }else if(old==31 && tmp==31){
                    check(_31_31);
                }else if(old==31 && tmp<30){
                    if(leap && tmp==29) c=false;
                    else{
                        if(tmp==29) leap=true;
                        if(possible.contains(0)){
                            possible.clear();
                            possible.add(1);
                        }
                    }
                }else if (old<30){
                    if(!possible.contains(1)) c=false;
                    else if(tmp==31){
                        possible.clear();
                        possible.add(2);
                    }
                }
                if(possible.isEmpty())c=false;
                else old=tmp;
            }
            n--;
        }
        System.out.println(c?"YES":"NO");
    }
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		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,29,31,30,31,30,31,31,30,31,30,31};
		int[] x = new int[n];
		for(int i = 0; i < n;i++)
			x[i] = scan.nextInt();
		boolean canHappen = false;
		for(int i = 0 ; i < m.length && !canHappen;i++)
		{
			canHappen = true;
			for(int j = 0 ;j < x.length && canHappen;j++)
				if(x[j] != m[(i+j)%m.length])
					canHappen = false;
		}
		if(canHappen)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

import java.util.*;
import java.io.*;

public class B
{

    Reader in;
    PrintWriter out;
    int i = 0, j = 0;
    void solve()
    {

        //START//
        int days[]={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};
        ArrayList<Integer> dl = new ArrayList<Integer>();
        for (i = 0; i < days.length; i++)
            dl.add((Integer)days[i]);
        ArrayList<Integer> inp = new ArrayList<Integer>();
        int n = in.nextInt();
        for (i = 0; i < n; i++)
        {
            int x = in.nextInt();
            inp.add((Integer)x);
        }
        if (Collections.indexOfSubList(dl, inp) == -1)
        {
            out.println("No");
        }
        else
            out.println("Yes");

        //END

    }
    void runIO()
    {
        in = new Reader();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args)
    {
        new B().runIO();
    }

    // input/output
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);

            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public final String next()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt()
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong()
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.')
                while ((c = read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);
            if (neg)
                return -ret;
            return ret;
        }

        public int[] readIntArray(int size)
        {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public long[] readLongArray(int size)
        {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        private void fillBuffer()
        {
            try
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            }
            catch (IOException e)
            {

            }

            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read()
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
    }
}

import java.util.Scanner;

public class Partition {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        input.nextLine();
      String a=input.nextLine();

        String x ="31 28 31 30 31 30 31 31 30 31 30 31 ";
        String x1 ="31 29 31 30 31 30 31 31 30 31 30 31 ";
        String x3=x+x1+x+x+x+x1+x+x;
        //System.out.println(x3);
        if(x3.contains(a)){
            System.out.println("yes");
        }else{
            System.out.println("no");
        }

    }
}

import java.io.*;

public class MonthsAndYears
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String data = "31 28 31 30 31 30 31 31 30 31 30 31";
		String data1 = "31 29 31 30 31 30 31 31 30 31 30 31";
		int n = Integer.parseInt(in.readLine());
		String input = in.readLine().trim();
		String a = data+" "+data+" "+data+" "+data1+" "+data+" "+data+" "+data;
		if(a.contains(input))
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}

	}
}

import java.util.*;
public class calender
{
public static void main(String[] args)
{
int k,l=0,n,i,j,flag=0;
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
int[] a=new int[n];
for(i=0;i<n;i++)
  a[i]=sc.nextInt();
int[] b=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
for(i=0;i<12;i++)
{flag=0;
 k=i;
 for(j=0;j<n;j++)
 {
   if(k==12)
     k=0;
   if(a[j]==b[k]||(a[j]==29&&k==1&&l!=1))
    { flag++;
      if(a[j]==29)
          l=1;
      k++;
     }
   else
      break;
 }
 if(flag==n)
   break;
}
if(flag==n)
System.out.println("YES");
else
System.out.println("NO");
}}

import java.util.Scanner;

public class Temp2
{
	public static void main(String[] args)
	{
		Scanner obj = new Scanner(System.in);
		int days[] = new int[]{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};

		int n = obj.nextInt();
		int[] ar = new int[n];
		for(int i=0 ; i<n ; i++)
			ar[i] = obj.nextInt();

		for(int i=0 ; i<days.length-ar.length ; i++)
		{
			int flag =0;
			for(int j=0 ; j<ar.length ;j++)
			{
				if(days[i+j]!=ar[j])
				{
					flag=1;
					break;
				}
			}

			if(flag==0)
			{
				System.out.println("YES");
				return;
			}
		}

		System.out.println("NO");
	}
}

import java.util.*;
import java.io.*;

public class B
{

    Reader in;
    PrintWriter out;
    int i = 0, j = 0;
    void solve()
    {

        //START//
        int days[]={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};
        ArrayList<Integer> dl = new ArrayList<Integer>();
        for (i = 0; i < days.length; i++)
            dl.add((Integer)days[i]);
        ArrayList<Integer> inp = new ArrayList<Integer>();
        int n = in.nextInt();
        for (i = 0; i < n; i++)
        {
            int x = in.nextInt();
            inp.add((Integer)x);
        }
        if (Collections.indexOfSubList(dl, inp) == -1)
        {
            out.println("No");
        }
        else
            out.println("Yes");

        //END

    }
    void runIO()
    {
        in = new Reader();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args)
    {
        new B().runIO();
    }

    // input/output
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);

            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public final String next()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt()
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong()
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.')
                while ((c = read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);
            if (neg)
                return -ret;
            return ret;
        }

        public int[] readIntArray(int size)
        {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public long[] readLongArray(int size)
        {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        private void fillBuffer()
        {
            try
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            }
            catch (IOException e)
            {

            }

            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read()
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
    }
}

import java.util.Scanner;

public class Partition {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        input.nextLine();
      String a=input.nextLine();

        String x ="31 28 31 30 31 30 31 31 30 31 30 31 ";
        String x1 ="31 29 31 30 31 30 31 31 30 31 30 31 ";
        String x3=x+x1+x+x+x;
        //System.out.println(x3);
        if(x3.contains(a)){
            System.out.println("yes");
        }else{
            System.out.println("no");
        }

    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Try
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
     int []a = new int[13];
     for(int i=1;i<=12;i++)
     {
         if(i%2==0)
             a[i] = 30;
         else
             a[i] = 31;
     }

     a[2] = 28;
     a[8] = 31;
     int x = sc.ni();
     int []ar = sc.nia(x);
     int f = 0;
     int c = 0;
     int z = 0;
     int m = 0;
     int l = 1;
     int le = 0;
     int p = 0;
     for(int i=0;i<x;i++)
     {

         if(ar[i] == 31)
         {
             l++;
             if(c == 2)
             {
                 f = 1;
                 break;
             }
             c++;
             m = 1;
             z = 0;
             p = 0;
         }
         if(ar[i] == 30)
         {
             l++;
             if(z == 1 || p == 1)
             {
                 f = 1;
                 break;
             }
             else
             {
             z = 1;
             c = 0;
             p = 0;
             m = 0;
             }
         }
         if(ar[i] == 28 || ar[i] == 29)
         {
             if(z == 1 || c > 2 || (le==1 && l!=12))
             {
                 f = 1;
                 break;
             }
             else
             {
                 le = 1;
                 p = 1;
             }
         }
     }
     if(f == 1)
         w.println("No");
     else
         w.println("Yes");

      w.close();

    }

     static class Student
    {

        int index;
        int diff;
        Student(int index,int diff)
        {
            this.index = index;
            this.diff = diff;

        }

    }

     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static int primeFactors(int n,int x)
    {
        as = new ArrayList<>();
        int sum = 0;
        // Print the number of 2s that divide n
        while (n%2==0)
        {

            if(sum == x-1)
                break;
            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;
            sum++;
        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");
                if(sum == x-1)
                break;
                as.add(i);
                n /= i;
                sum++;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {
            sum++;
            as.add(n);
        }
            return sum;
    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

    if(n == 2)
        return true;
    if(n == 3)
        return true;
    if(n % 2 == 0)
        return false;
    if(n % 3 == 0)
        return false;

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static boolean binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;

        while(st <= end)
        {
            int mid = st + (end-st)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else if(p == arr[mid])
            {

            re = true;
            break;
            }

        }
         return re;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hsy
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] month = new int[]{
                    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[] month2 = new int[]{
                    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 n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < month.length; i++) {
                if (a[0] == month[i]) {
                    int l = i;
                    for (int j = 0; j < n; j++) {
                        if (l < month.length && a[j] == month[l]) {
                            l++;
                        } else {
                            break;
                        }
                    }
                    if ((l - i) == n) {
                        out.println("Yes");
                        return;
                    }
                }
            }
            for (int i = 0; i < month2.length; i++) {
                if (a[0] == month2[i]) {
                    int l = i;
                    for (int j = 0; j < n; j++) {
                        if (l < month2.length && a[j] == month2[l]) {
                            l++;
                        } else {
                            break;
                        }
                    }
                    if ((l - i) == n) {
                        out.println("Yes");
                        return;
                    }
                }
            }
            out.println("No");
        }

    }
}

import java.util.*;
import java.io.*;
import java.util.function.LongPredicate;

public class ProblemD
{

    static int mod = (int) (1e9+7);
    static InputReader in;
    static PrintWriter out;

    static void solve()
    {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] b = new int[]{
                        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[] arr = in.nextIntArray(n);
        boolean ok = false;

        for(int i = 0; i < b.length; i++){
            int j = 0;
            int x = i;
            while(j < arr.length && x < b.length){
                if(arr[j] == b[x]){
                    x++;
                    j++;
                }
                else break;
            }
            if(j == arr.length){
                ok = true;
                break;
            }
        }

        out.println(ok?"YES":"NO");
        out.close();
    }

    public static void main(String[] args)
    {
        new Thread(null ,new Runnable(){
            public void run(){
                try{
                    solve();
                } catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();

    }

    static class Pair implements Comparable<Pair>
    {

        long x,y;

        Pair (long x,long y)
        {
                this.x = x;
                this.y = y;
        }
        public int compareTo(Pair o)
        {
            return Long.compare(this.x,o.x);
                //return 0;
        }

        public boolean equals(Object o)
        {
            if (o instanceof Pair)
            {
                Pair p = (Pair)o;
                return p.x == x && p.y==y;
            }
            return false;
        }

        @Override
        public String toString()
        {
            return x + " "+ y ;
        }

        /*public int hashCode()
        {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }*/

    }

    static long add(long a,long b){
        long x=(a+b);
        while(x>=mod) x-=mod;
        return x;
    }

    static long sub(long a,long b){
        long x=(a-b);
        while(x<0) x+=mod;
        return x;
    }

    static long mul(long a,long b){
        long x=(a*b);
        while(x>=mod) x-=mod;
        return x;
    }

    static String rev(String s){
        StringBuilder sb=new StringBuilder(s);
        sb.reverse();
        return sb.toString();
    }

    static long gcd(long x,long y)
    {
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static int gcd(int x,int y)
    {
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static long pow(long n,long p,long m)
    {
         long  result = 1;
          if(p==0){
            return 1;
          }

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            if(result >= m)
               result %= m;
            p >>=1;
            n*=n;
            if(n >= m)
                n%=m;
        }

        return result;
    }

    static long pow(long n,long p)
    {
        long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            p >>=1;
            n*=n;
        }
        return result;
    }

    static void debug(Object... o)
    {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader
    {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
                this.stream = stream;
        }

        public int snext()
        {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars)
                {
                        curChar = 0;
                        try
                        {
                                snumChars = stream.read(buf);
                        } catch (IOException e)
                        {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n)
        {
                int a[] = new int[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n)
        {
                long a[] = new long[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextLong();
                }
                return a;
        }

        public String readString()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }

        public String nextLine()
        {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c)
        {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter
        {
                public boolean isSpaceChar(int ch);
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/** Class for buffered reading int and double values */
public class A{
    public static void main(String[] args) throws IOException {
        Reader.init( System.in ); // connect Reader to an input stream
        //double x = Reader.nextDouble();
        //String s = Reader.next();
        int n = Reader.nextInt();
        //long ax = Reader.nextLong();
        int[] arr = new int[n];
        int count1 = 0;
        int[] arr1 = {31,28,31,30,31,30,31,31,30,31,30,31};
        int[] arr2 = {31,29,31,30,31,30,31,31,30,31,30,31};
        for(int i =0 ; i<n; i++) {
            arr[i] = Reader.nextInt();
        }
        int count = 0;

        for (int j = 0; j<12-n;j++) {
            int[] newArray = Arrays.copyOfRange(arr1, j, j+n);
            int[] newArray2 = Arrays.copyOfRange(arr2, j, j+n);

            if(Arrays.equals(arr, newArray) || Arrays.equals(arr, newArray2)){
               count ++;
            }
        }
        if (count>0){
            System.out.println("yes");
        }
        else{
            System.out.println("no");
        }
    }

    static void parr(int[] array,String seperator){
        String sep  = "";
        for(int var : array){
            System.out.print(sep + var);
            sep = seperator;
        }
        System.out.println();
    }

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    static String nextToken() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() {
        return Long.parseLong(nextToken());
    }

}

import java.io.File;
import java.io.FileNotFoundException;
    import java.util.*;
import javafx.util.Pair;

   public class Main {

    public static void main(String[] args) throws FileNotFoundException{
//        File f = new File("input.txt");
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String s1 = "312831303130313130313031312831303130313130313031";
        String s2 = "312931303130313130313031312831303130313130313031";
        String check="";
        for (int i = 0; i < n; i++) {
            check+=input.nextInt();
        }
        if(s1.contains(check))
        {
            System.out.println("YES");
        }
        else if(s2.contains(check))
        {
            System.out.println("YES");
        }
        else
            System.out.println("NO");

    }

}

import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        PrintWriter cout = new PrintWriter(System.out, true);
        Scanner cin = new Scanner(System.in);

        StringBuilder res = new StringBuilder();

        int n = cin.nextInt();

        String test = "";

        String normal="31 28 31 30 31 30 31 31 30 31 30 31 ";
        String leap="31 29 31 30 31 30 31 31 30 31 30 31 ";

        for (int i = 0; i < n; i++) {
            test += cin.next() + " ";
        }

        String years = normal+leap+normal+normal;

        int len = years.length();

        years = years.replace(test, "");

        cout.println(years.length()<len?"Yes":"No");
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] year = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            for (int i = 0; i < 12; i++) {
                int fabDif = 0;
                int dif = 0;
                for (int j = 0; j < n; j++) {
                    if (a[j] != year[(j + i) % 12]) {
                        dif++;
                        if ((j + i) % 12 == 1) fabDif++;
                    }
                }
                if (dif == 0) {
                    out.println("Yes");
                    return;
                }
                if (dif == 1 && fabDif == 1) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }

    static class InputReader {
        private StringTokenizer tokenizer;
        private BufferedReader reader;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        private void fillTokenizer() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        public String next() {
            fillTokenizer();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

//package math_codet;
import java.io.*;
import java.util.*;

public class lets_do {
    static int max(int a, int b,int c){
        return Math.max(a,Math.max(b,c));
    }
    public static void main(String[] args)
    {
        InputReader in=new InputReader(System.in);
        StringBuffer str=new StringBuffer();
        int[] arr1={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[] arr2={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[] arr3={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 n=in.nextInt();
        int i=0,j=0;
        int[] arr=new int[n];
        for(i=0;i<n;i++)
            arr[i]=in.nextInt();
        for(i=0;i<24;i++){
            if(arr1[i]==arr[0] && i+n<24){
                int k=0;
                boolean flag=false;
                for(j=0,k=i;j<n;j++){
                    if(arr[j]!=arr1[k]){
                        flag=true;
                        break;
                    }
                    k++;
                }
                if(!flag){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        for(i=0;i<24;i++){
            if(arr2[i]==arr[0] && i+n<24){
                int k=0;
                boolean flag=false;
                for(j=0,k=i;j<n;j++){
                    if(arr[j]!=arr2[k]){
                        flag=true;
                        break;
                    }
                    k++;
                }
                if(!flag){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        for(i=0;i<24;i++){
            if(arr3[i]==arr[0] && i+n<24){
                int k=0;
                boolean flag=false;
                for(j=0,k=i;j<n;j++){
                    if(arr[j]!=arr3[k]){
                        flag=true;
                        break;
                    }
                    k++;
                }
                if(!flag){
                    System.out.println("Yes");
                    System.exit(0);
                }
            }
        }
        System.out.println("No");
    }
    static class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

import java.util.*;
import java.io.*;
import java.util.function.LongPredicate;

public class ProblemD
{

    static int mod = (int) (1e9+7);
    static InputReader in;
    static PrintWriter out;

    static void solve()
    {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);

        int n = in.nextInt();
        int[] b = new int[]{
                        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

        };
        int[] arr = in.nextIntArray(n);
        boolean ok = false;

        for(int i = 0; i < b.length; i++){
            int j = 0;
            int x = i;
            while(j < arr.length && x < b.length){
                if(arr[j] == b[x]){
                    x++;
                    j++;
                }
                else break;
            }
            if(j == arr.length){
                ok = true;
                break;
            }
        }

        out.println(ok?"YES":"NO");

        out.close();
    }

    public static void main(String[] args)
    {
        new Thread(null ,new Runnable(){
            public void run(){
                try{
                    solve();
                } catch(Exception e){
                    e.printStackTrace();
                }
            }
        },"1",1<<26).start();

    }

    static class Pair implements Comparable<Pair>
    {

        long x,y;

        Pair (long x,long y)
        {
                this.x = x;
                this.y = y;
        }
        public int compareTo(Pair o)
        {
            return Long.compare(this.x,o.x);
                //return 0;
        }

        public boolean equals(Object o)
        {
            if (o instanceof Pair)
            {
                Pair p = (Pair)o;
                return p.x == x && p.y==y;
            }
            return false;
        }

        @Override
        public String toString()
        {
            return x + " "+ y ;
        }

        /*public int hashCode()
        {
            return new Long(x).hashCode() * 31 + new Long(y).hashCode();
        }*/

    }

    static long add(long a,long b){
        long x=(a+b);
        while(x>=mod) x-=mod;
        return x;
    }

    static long sub(long a,long b){
        long x=(a-b);
        while(x<0) x+=mod;
        return x;
    }

    static long mul(long a,long b){
        long x=(a*b);
        while(x>=mod) x-=mod;
        return x;
    }

    static String rev(String s){
        StringBuilder sb=new StringBuilder(s);
        sb.reverse();
        return sb.toString();
    }

    static long gcd(long x,long y)
    {
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static int gcd(int x,int y)
    {
        if(y==0)
                return x;
        else
                return gcd(y,x%y);
    }

    static long pow(long n,long p,long m)
    {
         long  result = 1;
          if(p==0){
            return 1;
          }

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            if(result >= m)
               result %= m;
            p >>=1;
            n*=n;
            if(n >= m)
                n%=m;
        }

        return result;
    }

    static long pow(long n,long p)
    {
        long  result = 1;
          if(p==0)
            return 1;

        while(p!=0)
        {
            if(p%2==1)
                result *= n;
            p >>=1;
            n*=n;
        }
        return result;
    }

    static void debug(Object... o)
    {
            System.out.println(Arrays.deepToString(o));
    }

    static class InputReader
    {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
                this.stream = stream;
        }

        public int snext()
        {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars)
                {
                        curChar = 0;
                        try
                        {
                                snumChars = stream.read(buf);
                        } catch (IOException e)
                        {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int nextInt()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public long nextLong()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public int[] nextIntArray(int n)
        {
                int a[] = new int[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextInt();
                }
                return a;
        }

        public long[] nextLongArray(int n)
        {
                long a[] = new long[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextLong();
                }
                return a;
        }

        public String readString()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }

        public String nextLine()
        {
                int c = snext();
                while (isSpaceChar(c))
                        c = snext();
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c)
        {
                return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter
        {
                public boolean isSpaceChar(int ch);
        }

    }
}

import java.util.*;
import java.math.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

     //--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<-------------------

public class a{
     static long[] count,count1,count2;
     static Node[] nodes;
     static long[] arr;
     static int[] dp;
     static char[] ch,ch1;
     static long[] darr,farr;
     static char[][] mat,mat1;
     static long x,h;
     static long maxl;
     static double dec;
     static long mx = (long)1e9+7;
     static String s;
     static long minl;
     static int start_row;
     static int start_col;
     static int end_row;
     static int end_col;
     static long mod = (long)1e7+7;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static int a;
     static int b;
     static long c;
     static long d;
     static long y,z;
     static int m;
     static int k;
     static String[] str,str1;
     static Set<Long> set,set1,set2;
     static SortedSet<Long> ss;
     static List<Integer> list,list1,list2,list3;
     static LinkedList<Node> ll;
     static Map<Integer,List<Integer>> map,map1;
     static StringBuilder sb,sb1,sb2;
     static int index;
     static int[] dx = {0,-1,0,1,-1,1,-1,1};
     static int[] dy = {-1,0,1,0,-1,-1,1,1};

     // public static void solve(){

     //    FastScanner sc = new FastScanner();
     //    // int t = sc.nextInt();
     //    int t = 1;
     //    for(int tt = 0 ; tt < t ; tt++){
     //        int n = sc.nextInt();
     //        int m = sc.nextInt();
     //        int prev = 0;

     //        for(int i = 0 ; i < n ; i++){
     //           int s = sc.nextInt();
     //           int e = sc.nextInt();
     //           if(s > prev){
     //                System.out.println("NO");
     //                return;
     //           }
     //            prev = Math.max(prev,e);
     //        }
     //        if(prev == m)
     //            System.out.println("YES");
     //        else
     //            System.out.println("NO");

     //        // System.out.println(sb);
     //    }

     // }

     //--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<-------------------

     public static void solve(){

        long[] days = {31,28,31,30,31,30,31,31,30,31,30,31};

        for(int i = 0 ; i < 12 ; i++){
            int k = i-1;
            for(int j = 0 ; j < n ; j++){
                k += 1;
                k %= 12;

                if(arr[j] == 29 && days[k] == 28){
                    if(j == n-1){
                        System.out.println("YES");
                        return;
                    }
                    continue;
                }

                if(arr[j] != days[k]){
                    break;
                }
                if(j == n-1){
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            // int l = 1;
            while(t > 0){

                n = sc.nextInt();
                // n = sc.nextLong();
                // a = sc.nextInt();
                // b = sc.nextInt();
                // c = sc.nextLong();
                // d = sc.nextLong();

                // x = sc.nextLong();
                // y = sc.nextLong();

                // n = sc.nextLong();
                // n = sc.nextInt();
                // n1 = sc.nextInt();

                // m = sc.nextInt();

                // k = sc.nextInt();
                // s = sc.next();

                // ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                arr = new long[n];
                for(int i = 0 ; i < n ; i++){
                    arr[i] = sc.nextLong();
                }
                // // m = n;
                // darr = new long[n];
                // for(int i = 0; i < n ; i++){
                //     darr[i] = sc.nextLong();
                // }

                // farr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     farr[i] = sc.nextInt();
                // }

                // mat = new char[n][m];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < m ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }

                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // nodes = new Node[n];
                // for(int i = 0 ; i < n ;i++)
                //     nodes[i] = new Node(sc.nextInt(),sc.nextInt());

                // System.out.println(solve()?"YES":"NO");
                 solve();
                 // System.out.println(solve());
                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

    public static boolean isPrime(long n) {
    // Corner cases
        if (n <= 1)
            return false;

        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n%2 == 0 || n%3 == 0)
            return false;

        for (int i=5; i*i<=n; i=i+6)
            if (n%i == 0 || n%(i+2) == 0)
               return false;

        return true;
    }

     public static long gcd(long a,long b){

        if(b%a == 0){
            return a;
        }
        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // }

    static final Random random=new Random();

    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        Integer first;
        Integer second;
        Node(Integer f,Integer s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }

                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}

//package kanak;
import java.util.*;
import java.lang.*;
import java.io.*;
public  class Solution{
    public  static  void main(String [] args){
        InputReader fi=new InputReader(System.in);
        int [] leap={31,29,31,30,31,30,31,31,30,31,30,31};
        int [] nonleap={31,28,31,30,31,30,31,31,30,31,30,31};
        boolean ans=false;
        int n=fi.nextInt();
        int i,j,k,t;
        int a[]=new int[n];
        for (i=0;i<n;i++)
            a[i]=fi.nextInt();

            int l=0;
            int [] b=new int[12];
            int offset=0;
            while (n > 0) {

                Arrays.fill(b,0);
                if (n > 12)
                    l=12;
                else
                    l=n;

                for (i = 0; i < l; i++) {
                    b[i] = a[i+offset];
                }
                offset=offset+l;
                ans=check(leap,nonleap,l,b);
                if (!ans) {
                    break;
                }

                n=n-12;
        }

        if (ans)
        {
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }

    static boolean check(int [] leap,int[] nonleap,int n,int [] a){
        int i,j,k;
        boolean ans=false;

        for (i=0;i<12;i++){
            for (j=0,k=i;j<n;j++,k++){
                if (leap[k%12] == a[j])
                    continue;

                else
                    break;
            }
            if (j==n) {
                ans = true;
                break;
            }
        }
        if (ans)
            return  ans;

        for (i=0;i<12 ;i++){
            for (j=0,k=i;j<n;j++,k++){
                if (nonleap[k%12] == a[j])
                    continue;
                else
                    break;
            }
            if (j==n) {
                ans = true;
                break;
            }
        }
        return  ans;
    }

}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int snext() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = snext();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = snext();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n+1];
        for (int i = 1; i <= n; i++)
            a[i] = nextInt();
        return a;
    }

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.stream.Collectors;

public class CFB {
    private static final long MOD = 1_000_000_007L;
    private static final long LIMIT = 1L << 60; //10^18

    static FastScanner sc;
    static int[] as;
    static int[] months1 = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    static int[] months2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public static void main(String[] args) {
        sc = new FastScanner(System.in);

        int n = sc.nextInt();
        as = readIntArray(n);
//        Map<Integer, Integer> map = Arrays.stream(as).boxed().collect(Collectors.toMap(i -> i, i -> 1, (a, b) -> a + 1));

        int[] months = new int[12*4];
        System.arraycopy(months1, 0, months, 0, 12);
        System.arraycopy(months2, 0, months, 12, 12);
        System.arraycopy(months1, 0, months, 24, 12);
        System.arraycopy(months1, 0, months, 36, 12);

        for (int i = 0; i < 24; i++) {
            boolean yes = true;
            for (int j = i; j < i+ n; j++) {
                if (as[j-i] != months[j]) {
                    yes = false;
                    break;
                }
            }

            if (yes) {
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");
    }

    //********************************************************************************************
    //********************************************************************************************
    //********************************************************************************************

    private static int ceil(double d) {
        int ret = (int) d;
        return ret == d ? ret : ret + 1;
    }

    private static int round(double d) {
        return (int) (d + 0.5);
    }

    @SuppressWarnings("SameParameterValue")
    private static <T> T elvis(T obj, T defValue) {
        return obj == null ? defValue : obj;
    }

    private static int gcd(int a, int b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    private static int[] readIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextInt();
        }
        return res;
    }

    private static long[] readLongArray(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextLong();
        }
        return res;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int t=Integer.parseInt(br.readLine());
    // while(t-->0)

      String query=br.readLine();
      String s="31 28 31 30 31 30 31 31 30 31 30 31 ";
      s=s+s;
      s=s+s;
      String w="31 29 31 30 31 30 31 31 30 31 30 31 ";
      w=w+w;
      w=w+w;
      s=s+w;
      if(s.contains(query))
        System.out.println("YES");
      else
      {

        System.out.println("NO");

      }
      br.close();
   }
}

import java.util.Scanner;

public class hello {
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int[] ar=new int[n];
        for(int i=0;i<n;i++)
            ar[i]=ob.nextInt();
        int flag=0,flag1=0,flag2=0,len=0,c=0;
        int[] mon={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
        for(int i=0;i<24;i++)
        {
            for(int j=i;j<24;j++)
            {
                if(ar[c]==29&&(mon[j]==29||mon[j]==28)&&flag!=1)
                {flag=1;c++;len++;if(len==n){flag2=1;break;}}
                else if(ar[c]==28&&(mon[j]==29||mon[j]==28))
                {len++;c++;if(len==n){flag2=1;break;}}
                 else if(flag==1&&ar[c]==29)
                {flag1=1;break;}
                 else if(ar[c]==mon[j])
                {c++;len++;if(len==n){flag2=1;break;}}
                else {len=0;c=0;break;}
            }
            if(flag1==1||flag2==1)
                break;
        }
        if(flag2==1)
            System.out.println("Yes");
        else System.out.println("No");
    }
}

import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		boolean fair = true;
		boolean leaped = false;
		for(int i = 0; i < n; i++){
			shiva[i] = input.nextInt();
		}

		for(int i = 0; i < n-1; i++){
			if(shiva[i] == 28 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 29 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 30 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 31){
				if(i != 0 && shiva[i-1] == 31 && shiva[i+1] == 31){
					fair = false;
				}

				if(i != 0 && shiva[i-1] != 31){ // precondition fix for before and after feb, find howmany months there are
					if(shiva[i+1] == 28 || shiva[i+1] == 29)
						fair = false;
				}

				if(i == 0 && shiva[i+1] != 31 && shiva[i+1] != 30 && shiva[i+1] != 29 && shiva[i+1] != 28)
					fair = false;
			}

			if(leaped == true)
				fair = false;

			if(shiva[i] == 29){
				leaped = true;
			}
		}

		if(fair == false){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}

	}
}

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int t=Integer.parseInt(br.readLine());
    // while(t-->0)

      String query=br.readLine();
      String s="31 28 31 30 31 30 31 31 30 31 30 31";
      s=s+s;
      s=s+s;
      String w="31 29 31 30 31 30 31 31 30 31 30 31";
      w=w+w;
      w=w+w;
      if(s.contains(query))
        System.out.println("YES");
      else
      {
        if(w.contains(query))
        System.out.println("YES");
        else
        System.out.println("NO");

      }
   }
}

import java.util.Arrays;
import java.util.Scanner;

public class Partition {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = input.nextInt();
            //a.add(x);
        }
        String x = Arrays.toString(a);
        //System.out.println(x);
        if (x.contains("30, 30") || x.contains("30, 28") || x.contains("30, 29")) {
            System.out.println("no");
        } else if (x.contains("28, 30") || x.contains("29, 30")) {
            System.out.println("no");
        } else {
            System.out.println("yes");
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Months {
	public static void main(String[]args) throws IOException{
		String s1 = "-1 31 28 31 30 31 30 31 31 30 31 30 31";
		String s2 = "-1 31 29 31 30 31 30 31 31 30 31 30 31";

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		int n  = Integer.parseInt(bf.readLine());
		String in[] = bf.readLine().split(" ");

		int leap =0;
		for(int i = 0 ; i < n ; i++)if(Integer.parseInt(in[i])==29)leap++;

		if(leap>1){
			System.out.println("No\n");
			return;
			}

		boolean out=false;
	if(n>12){
		out=(isSubstring(s1.split(" "), in, 0,12 )||isSubstring(s2.split(" "), in, 0,12))
				&&(isSubstring(s1.split(" "), in, 12, n)||isSubstring(s2.split(" "), in, 12,n));;
	}else{
		System.out.println(isSubstring(s2.split(" "), in, 0,n));
		out=isSubstring(s1.split(" "), in, 0,n)||isSubstring(s2.split(" "), in, 0,n);
	}

		if(out)System.out.println("Yes\n");
		else System.out.println("No\n");

	}
	static boolean isSubstring(String s[],String in[],int start , int end){
		boolean out = false;
		int temp;
		for(int i = 1 ; i <=  12 ; i++){
			if(s[i].equals(in[start])){
				out=true;
				int j;temp=i+1;
				if(temp>12)temp=1;
				for(j = start+1  ;temp<=12 && j<end ;j++){
					if(!(in[j].equals(s[temp]))){
						out=false;
						break;

					}
					if(++temp>12)temp=1;
				}
				if(out&&j==end)return true;
			}
		}
	return false;
	}
}

import java.util.Scanner;

public class B899 {
    public static void main(String[] args) {
        final String monthSeq1 = "312831303130313130313031312831303130313130313031";
        final String monthSeq2 = "312931303130313130313031312931303130313130313031";
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = "";
        for (int i = 0;i < n;i++) s += in.next();
        s = s.trim();
        System.out.println(monthSeq1.contains(s) || monthSeq2.contains(s) ? "YES": "NO");
    }
}

import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    static int[] days =
        new int[]{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, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int consecutive = 0;
        boolean include = false;
        int start = 0;
        for (int i = 0; i < days.length; i++) {
            if (days[i] == a[i - start]) {
                consecutive++;
                if (consecutive == n) {
                    include = true;
                    break;
                }
            } else {
                start = i + 1;
                consecutive = 0;
            }
        }
        System.out.println(include ? "YES" : "NO");

    }
}

import java.io.*;
import java.util.*;
public class B
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out=new StringBuilder("");
        StringTokenizer st;
        int n=Integer.parseInt(br.readLine());
        String p1="31 28 31 30 31 30 31 31 30 31 30 31";
        String p2="31 29 31 30 31 30 31 31 30 31 30 31";
        p1=p1+" "+p1+" "+p1;
        p2=p2+" "+p2+" "+p2;
        String in=br.readLine();
        boolean bool=(p1.indexOf(in)!=-1 || p2.indexOf(in)!=-1);
        System.out.print(bool ? "YES" : "NO");
    }
}

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		int N = input.nextInt();

		int[] sequence = {
						31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31,
						31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31,
						31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31,
						31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31,
						31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31,
						31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 31, 30, 31, 30, 31};

		Queue<Integer> pq = new LinkedList<Integer>();

		for (int i = 0; i < N; i++) {
			int num = input.nextInt();
			if (i == 0) {
				for (int state = 0; state < sequence.length; state++)
					if (sequence[state] == num)
						pq.add(state);
			} else {
				LinkedList<Integer> next = new LinkedList<>();
				while (!pq.isEmpty()) {
					int state = pq.poll();
					if (state == sequence.length - 1) continue;
					if (sequence[state + 1] == num)
						next.add(state + 1);
				}
				pq.addAll(next);
			}
		}

		if (pq.isEmpty())
			System.out.println("NO");
		else
			System.out.println("YES");
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package months.years;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Asad Abbas
 */

public class MonthsYears {

   public static class numbers{
       public int  num =0;
       public int index =0;
       public numbers(int num , int index){
           this.num = num;
           this.index = index;
       }
   }
    /**
     * @param args the command line arguments
     */
    public static boolean check(List<Integer> arr , int [] check){
        for (int i = 0; i < arr.size(); i++) {
            if(arr.get(i) != check[i]){
                return false;
            }
        }
        return true;
    }
    public static int getindex(List<numbers> arr , int count , int num){
        int countcheck = 1;
        List<numbers> temp = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            numbers abc = arr.get(i);
            if(abc.num == num){
                temp.add(abc);
            }
        }
        for (int i = 0; i < temp.size(); i++) {
            if(countcheck == count){
                return temp.get(i).index;
            }
            else{
                countcheck++;
            }
        }
        return -1;
    }
    static List<Integer>  getseq(int [] arr , int i , int count){
        List<Integer> arrr = new ArrayList<>();
        while (count-->0) {
            arrr.add(arr[i]);
            i++;
            if(i >= arr.length){
                i=0;
            }
        }
        return arrr;
    }
    public static void main(String[] args) {
        int [] months = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        List<numbers> data = new ArrayList<>();

        for (int i = 0; i < months.length; i++) {
            data.add(new numbers(months[i],i));
        }
        boolean abc = true;
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] arr = new int[n];
        int start = 0;
        while (n-->0) {
            int a = s.nextInt();
            if( a == 29){
                a--;
            }
            arr[start] = a;
            start++;
        }

       int count = 1;
       boolean flag = true;
        for (int i = 0; i < 24; i++) {
            int index = getindex(data , count , arr[0]);
            if(index != -1){
                List<Integer> news = getseq(months , index , arr.length);

                if(check(news , arr)){
                    flag = false;
                    System.out.println("Yes");
                    break;
                }
            }
            count++;
        }
        if(flag){
             System.out.println("No");
        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class codforecesdiv2 {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int t = fr.nextInt();
        String s=new String();
        String s1="";
        String s2="312831303130313130313031312831303130313130313031312831303130313130313031";
        String s3="312831303130313130313031312931303130313130313031312831303130313130313031";
        for (int i=0;i<t;i++){
        	s=fr.next();
        	s1=s1+s;
        }
        int counter=0;
        if (s2.contains(s1)){
        	counter++;
        }
        else if(s3.contains(s1)){
        	counter++;
        }
        if (counter>0){
        	System.out.println("YES");
        }
        else{
        	System.out.println("NO");
        }
    }
}

import java.util.*;
import java.io.*;

// public class Solution implements Runnable
class Solution implements Runnable
{
	public static void main(String[] args) throws IOException  {
		br=new BufferedReader(new InputStreamReader(System.in));
		nextIntBuffer = new String[0];
		bos = new OutputStreamWriter(new BufferedOutputStream(System.out));
		new Thread(null, new Solution(), "Main", 1<<28).start();
	}

	static BufferedReader br;
	static String nextIntBuffer[];
	static int nextIntBase;
	static OutputStreamWriter bos;
	static int nextInt() {
		return Integer.parseInt(next());
	}

	static long nextLong() {
		return Long.parseLong(next());
	}

	static String next() {
		try{
			if(nextIntBase>=nextIntBuffer.length) {
				nextIntBase =0;
				nextIntBuffer = br.readLine().split(" ");
			}
		}catch(IOException e) {}
		return nextIntBuffer[nextIntBase++];
	}

	static void print (String s)    {try{ bos.write(s);	}catch(IOException e){}}
	static void print (int s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void print (long s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void print (double s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void println (String s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (int s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (long s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (double s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}

		public static <T1 extends Comparable<T1> ,T2 extends Comparable<T2> > Pair<T1,T2> mp(T1 a,T2 b) {
		return new Pair<T1,T2>(a,b);
	}

	public void main()  {
		br=new BufferedReader(new InputStreamReader(System.in));
		nextIntBuffer = new String[0];

		int n=nextInt();
		// while(t-->0)
		{
			int[] a=new int[n];
			int thi0=0,thi1=0;
			for (int i=0;i<n ;i++ ) {
				a[i]=nextInt();
				if(a[i]==30)
					thi0++;
				else if(a[i]==31)thi1++;
			}
			int[] leap=new int[12];
			leap[0]=leap[2]=leap[4]=leap[6]=leap[7]=leap[9]=leap[11]=31;
			leap[3]=leap[5]=leap[8]=leap[10]=30;
			leap[1]=29;
			int[] noleap=Arrays.copyOf(leap,leap.length);
			noleap[1]=28;
			int pos=-1;
			for (int i=0;i<n ;i++ ) {
				if(a[i]<30){
					pos=i;
					break;
				}
			}
			boolean flag=true;
			if(pos>=0){
				for (int i=pos-1;i>=0 ;i-- ) {
					if(a[i]!=noleap[((i-pos+1)%12+12)%12])
					{
						if(a[i]>=30)
							flag=false;
						else if(a[pos]==29 && a[i]==29)
							flag=false;
					}
				}
				// println(pos);
				for (int i=pos+1;i<a.length ;i++ ) {
						// println(i+" "+a[i]+" "+noleap[((i-pos+1)%12+12)%12]);
					if(a[i]!=noleap[((i-pos+1)%12+12)%12])
					{
						if(a[i]>=30)
							flag=false;
						else if(a[pos]==29 && a[i]==29)

							flag=false;
					}
				}
			}
			else
			{
				for (int i=0;i<n-1 ;i++ ) {
					if(a[i]==31&&a[i+1]==31)
						pos=i;
				}
				if(pos>=0){
					for (int i=pos;i>=0 ;i-- ) {
						if(a[i]!=noleap[((i-pos+6)%12+12)%12])
						{

								flag=false;
						}
					}
					for (int i=pos+1;i<a.length ;i++ ) {
						if(a[i]!=noleap[((i-pos+6)%12+12)%12])
						{

								flag=false;
						}
					}

					if(!flag){
						for (int i=pos;i>=0 ;i-- ) {
							if(a[i]!=noleap[((i-pos+11)%12+12)%12])
							{

									flag=false;
							}
						}
						for (int i=pos+1;i<a.length ;i++ ) {
							if(a[i]!=noleap[((i-pos+11)%12+12)%12])
							{

									flag=false;
							}
						}
					}
				}
				else
				{
					if(Math.abs(thi0-thi1)<=1&&n<=5)
						flag=true;
					else flag=false;
				}
			}
			if(flag)
				println("Yes");
			else
				println("No");

		}
	}

	public void run() {
		try
		{
			main();
			bos.flush();
		}catch(IOException e) {
			e.printStackTrace();
		}
	}

	static long pow(long x,long y,long mod)
	{
		if (y==0) return 1;
		long z=pow(x,y/2,mod)%mod;
		if(y%2==0) return (z*z)%mod;
		else return (((x*z)%mod)*z)%mod;

	}

	static long gcd(long q,long d) {
		long x1[]=new long[1];long y1[]=new long[1];
		return  gcd(q,d,x1,y1);
	}
	static long gcd(long q,long d,long x[],long y[]) {
		if(d%q==0) {
			x[0]=1;
			y[0]=0;
			return q;
		}
		long x1[]=new long[1];long y1[]=new long[1];
		long ans = gcd(d%q,q,x1,y1);
		y[0]=x1[0];
		x[0]=y1[0]-(d/q)*x1[0];
		return ans;
	}
	static long Inv(long n,long m) {
		long x[]=new long[1];long y[]=new long[1];
		long g= gcd(n,m,x,y);
		if(g==1) {
			return (x[0]+m)%m;
		}
		return -1;
	}
}

class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2> > implements Comparable<Pair<T1,T2> > {
	  T1 a;
	  T2 b;
	  public Pair(T1 x, T2 y) {
	    a = x; b = y;
	  }
	  @Override
	  public int compareTo(Pair<T1,T2> other) {
	  	int comp1 = a.compareTo(other.a);
	  	if(comp1!=0)
	  		return comp1;
	    return b.compareTo(other.b);
	}
}

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int t=Integer.parseInt(br.readLine());
    // while(t-->0)

      String query=br.readLine();
      String s="31 28 31 30 31 30 31 31 30 31 30 31 ";
      s=s+s;
      s=s+s;
      String w="31 29 31 30 31 30 31 31 30 31 30 31 ";
      w=w+w;
      w=w+w;
      s=s+w;
      s=s+s;
      if(s.contains(query))
        System.out.println("YES");
      else
      {

        System.out.println("NO");

      }
      br.close();
   }
}

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int[] month = {31,28,31,30,31,30,31,31,30,31,30,31};
		int n = input.nextInt();
		String mon1 = "";
		String mon2 = "";
		String[] mon = new String [8];
		for(int i = 0;i < 12;i++){
			if(i == 1){
				mon1 += "29";
				mon2 += "28";
			}
			else{
				mon1 += String.valueOf(month[i]);
				mon2 += String.valueOf(month[i]);
			}
		}
		mon[0] = mon1 + mon1 + mon1;
		mon[1] = mon1 + mon1 + mon2;
		mon[2] = mon1 + mon2 + mon1;
		mon[3] = mon1 + mon2 + mon2;
		mon[4] = mon2 + mon1 + mon1;
		mon[5] = mon2 + mon1 + mon2;
		mon[6] = mon2 + mon2 + mon1;
		mon[7] = mon2 + mon2 + mon2;
		String target = "";
		for(int i = 0;i < n;i++)
			target += input.next();
		int sign = 0;
		for(int i = 0;i < 8;i++)
			if(mon[i].contains(target)){
				sign = 1;
				System.out.println("YES");
				break;
			}
		if(sign == 0)
			System.out.println("NO");
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();

		ArrayList<Integer> leap = new ArrayList<>();
		leap.add(31);
		leap.add(29);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(30);
		leap.add(31);

		ArrayList<Integer> nonLeap = new ArrayList<>();
		nonLeap.add(31);
		nonLeap.add(28);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);

		ArrayList<Integer> ans[] = new ArrayList[4];
		for (int i = 0; i < 4; i++)
			ans[i] = new ArrayList<>();
		ans[0].addAll(leap);
		ans[0].addAll(leap);
		ans[0].addAll(leap);

		ans[1].addAll(leap);
		ans[1].addAll(leap);
		ans[1].addAll(nonLeap);

		ans[2].addAll(leap);
		ans[2].addAll(nonLeap);
		ans[2].addAll(leap);

		ans[3].addAll(nonLeap);
		ans[3].addAll(leap);
		ans[3].addAll(leap);
		boolean ok = false;
		for (int i = 0; i < 4; i++) {
			ArrayList<Integer> cur = ans[i];
			outer: for (int st = 0; st + n < cur.size(); st++) {
				for (int j = 0; j < n; j++)
					if (cur.get(st + j) != arr[j]){
						continue outer;
					}
				ok = true;
			}
		}
		System.out.println(ok ? "YES" : "NO");
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}
	}
}

import java.util.*;
import java.util.Collections;
public class JavaApplication7 {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          int[] arr = new int[13];
          arr[1]=31;
          arr[2]=28;
          arr[3]=31;
          arr[4]=30;
          arr[5]=31;
          arr[6]=30;
          arr[7]=31;
          arr[8]=31;
          arr[9]=30;
          arr[10]=31;
          arr[11]=30;
          arr[12]=31;
          int n =input.nextInt();
          String answer = "Yes";
          String entry ="";

          for(int i=0;i<n;i++)
          {
                 int x =input.nextInt();

                 entry += x+" ";
          }
            entry=entry.replace("29", "28");
            String months= arr[1]+" "+arr[2]+" "+arr[3]+" "+arr[4]+" "+arr[5]+" "+arr[6]+" "+arr[7]+" "+arr[8]+" "+arr[9]+" "+arr[10]+" "+arr[11]+" "+arr[12]+" ";
            boolean found = months.contains(entry);

            if(found)System.out.println("Yes");
            else{
                StringBuffer months1=new StringBuffer(months);
                for(int i=1;i<=n;i++)
                    months1.append(months);

               int found1 = months1.indexOf(entry);
                if(found1!=-1)System.out.println("Yes");
                else System.out.println("No");

          }
      }}

/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
// 		int b[]=new int{31,28,31,30,31,30,31,31,30,31,30,31};
		int a[]=new int[n];
		int i,c=0, t8=0;
		for(i=0;i<n;i++){
		    a[i]=sc.nextInt();
		}
		if(a.length==1 && (a[0]==31||a[0]==30||a[0]==29||a[0]==28)){
		    System.out.println("Yes");
		}
		else if(a.length==1 && (a[0]!=31&&a[0]!=30&&a[0]!=29&&a[0]!=28)){
		    System.out.println("No");
		}
		else if(a.length>1){
		for(i=0;i<n-1;i++){
		  if(a[i]==30){
		      if(a[i+1]==31){
		          ++c;
		      }
		      else{
		          c=0;
		          break;
		      }
		  }
		  else if(a[i]==31){
		      if(a[i+1]==28||a[i+1]==29){
		          ++c;
		      }
		      else if(a[i+1]==30){
		          ++c;
		      }
		      else if(a[i+1]==31){
		          if(i<n-2){
		              if(a[i+2]==28||a[i+2]==29|| a[i+2]==30){
		                  ++c;
		              }
		              else{
		                  c=0;
		                  break;
		              }
		          }
		          else if(i==n-2){
		              ++c;
		          }
		          else{
		              c=0;
		              break;
		          }

		      }
		      else{
		          c=0;
		          break;
		      }
		  }
		  else if(a[i]==28||a[i]==29){

		      if(a[i+1]==31){
		          ++c;
		      }
		      else{
		          c=0;
		          break;
		      }

		  }
		}
		if(c==0){
		    System.out.println("No");
		}
		else{
		    System.out.println("Yes");
		}
		}
		else{
		    System.out.println("No");
		}
	}
}

import java.util.*;
import java.io.*;
public class Test
{
public static void main(String[] args) throws IOException
{
    String str="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 29 31 30 31 30 31 31 30 31 30 31";
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    sc.nextLine();
    String s=sc.nextLine();
    if(str.indexOf(s)>0){
        System.out.println("YES");
    }
    else{
        System.out.println("NO");
    }

}
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class B {
	static boolean compare(String str[], List<String> list) {
		for (int i = 0; i < str.length; ++i)
			if (!str[i].equals(list.get(i)))
				return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner jin = new Scanner(System.in);

		String leap[] = { "31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" };
		String norm[] = { "31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" };

		int n = jin.nextInt();

		String[] list = new String[n];

		for (int i = 0; i < n; ++i)
			list[i] = jin.nextInt() + "";

		ArrayList<String> generatedLeap = new ArrayList<String>();
		ArrayList<String> generatedNorm = new ArrayList<String>();
		ArrayList<String> generatedNorm1 = new ArrayList<String>();

		for (int i = 0; i < n + 12; ++i) {
			generatedLeap.add(leap[i % 12]);
			generatedNorm.add(norm[i % 12]);
			generatedNorm1.add(norm[i % 12]);
		}

		if (generatedLeap.indexOf("29") != generatedLeap.lastIndexOf("29")) {
			int index = generatedLeap.lastIndexOf("29");
			generatedLeap.set(index, "28");

			index = generatedNorm.lastIndexOf("28");
			generatedNorm.set(index, "29");
		}

		for (int i = 0; i < generatedLeap.size(); ++i) {
			if (i + n > generatedLeap.size())
				break;
			else {
				List<String> subList = generatedLeap.subList(i, i + n);
				if (compare(list, subList)) {
					System.out.println("Yes");
					return;
				}
				subList = generatedNorm.subList(i, i + n);
				if (compare(list, subList)) {
					System.out.println("Yes");
					return;
				}
				subList = generatedNorm1.subList(i, i + n);
				if (compare(list, subList)) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");

	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package months.years;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Asad Abbas
 */

public class MonthsYears {

   public static class numbers{
       public int  num =0;
       public int index =0;
       public numbers(int num , int index){
           this.num = num;
           this.index = index;
       }
   }
    /**
     * @param args the command line arguments
     */
    public static boolean check(List<Integer> arr , int [] check){
        for (int i = 0; i < arr.size(); i++) {
            if(arr.get(i) != check[i]){
                return false;
            }
        }
        return true;
    }
    public static int getindex(List<numbers> arr , int count , int num){
        int countcheck = 1;
        List<numbers> temp = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            numbers abc = arr.get(i);
            if(abc.num == num){
                temp.add(abc);
            }
        }
        for (int i = 0; i < temp.size(); i++) {
            if(countcheck == count){
                return temp.get(i).index;
            }
            else{
                countcheck++;
            }
        }
        return -1;
    }
    static List<Integer>  getseq(int [] arr , int i , int count){
        List<Integer> arrr = new ArrayList<>();
        while (count-->0) {
            arrr.add(arr[i]);
            i++;
            if(i >= arr.length){
                i=0;
            }
        }
        return arrr;
    }
    public static void main(String[] args) {
        int [] months = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        List<numbers> data = new ArrayList<>();

        for (int i = 0; i < months.length; i++) {
            data.add(new numbers(months[i],i));
        }
        boolean abc = true;
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] arr = new int[n];
        int [] copy = new int[n];
        int start = 0;
        while (n-->0) {
            int a = s.nextInt();
            int b = a;
            if( a == 29){
                a--;
            }
            arr[start] = a;
            copy[start] = b;
            start++;
        }

       int count = 1;
       boolean flag = true;
        for (int i = 0; i < 7; i++) {
            int index = getindex(data , count , arr[0]);
            if(index != -1){
                List<Integer> news = getseq(months , index , arr.length);

                if(check(news , arr)){
                    flag = false;

                    int a = 0;
                    int b = 0;
                    for (int j = 0; j < copy.length; j++) {
                        if(copy[j] == 28){
                            a++;
                        }
                        else if(copy[j] == 29){
                            b++;
                        }
                    }
                    if( a == 2 || b == 2){
                        System.out.println("No");
                    }
                    else{
                        System.out.println("Yes");
                    }
                    break;
                }
            }
            count++;
        }
        if(flag){
             System.out.println("No");
        }

    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package months.years;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Asad Abbas
 */

public class MonthsYears {

   public static class numbers{
       public int  num =0;
       public int index =0;
       public numbers(int num , int index){
           this.num = num;
           this.index = index;
       }
   }
    /**
     * @param args the command line arguments
     */
    public static boolean check(List<Integer> arr , int [] check){
        for (int i = 0; i < arr.size(); i++) {
            if(arr.get(i) != check[i]){
                return false;
            }
        }
        return true;
    }
    public static int getindex(List<numbers> arr , int count , int num){
        int countcheck = 1;
        List<numbers> temp = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            numbers abc = arr.get(i);
            if(abc.num == num){
                temp.add(abc);
            }
        }
        for (int i = 0; i < temp.size(); i++) {
            if(countcheck == count){
                return temp.get(i).index;
            }
            else{
                countcheck++;
            }
        }
        return -1;
    }
    static List<Integer>  getseq(int [] arr , int i , int count){
        List<Integer> arrr = new ArrayList<>();
        while (count-->0) {
            arrr.add(arr[i]);
            i++;
            if(i >= arr.length){
                i=0;
            }
        }
        return arrr;
    }
    public static void main(String[] args) {
        int [] months = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        List<numbers> data = new ArrayList<>();

        for (int i = 0; i < months.length; i++) {
            data.add(new numbers(months[i],i));
        }
        boolean abc = true;
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [] arr = new int[n];
        int start = 0;
        while (n-->0) {
            int a = s.nextInt();
            if( a == 28 && abc){
                months[1] = 28;
                abc = false;
            }
            else if( a == 29 && abc){
                months[1] = 29;
                abc = false;
            }

            arr[start] = a;
            start++;
        }

       int count = 1;
       boolean flag = true;
        for (int i = 0; i < 7; i++) {
            int index = getindex(data , count , arr[0]);
            if(index != -1){
                List<Integer> news = getseq(months , index , arr.length);

                if(check(news , arr)){
                    flag = false;
                    System.out.println("Yes");
                    break;
                }
            }
            count++;
        }
        if(flag){
             System.out.println("No");
        }

    }

}

import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		boolean fair = true;
		boolean leaped = false;
		boolean thirty1 = false;
		boolean thirty = false;
		boolean twenties = false;

		for(int i = 0; i < n; i++){
			shiva[i] = input.nextInt();
			if(shiva[i] == 28 ){
				twenties = true;
			}else if(shiva[i] == 29 ){
				twenties = true;
			}else if(shiva[i] == 30 ){
				thirty = true;
			}else if(shiva[i] == 31){
				thirty1 = true;
			}
		}

		for(int i = 0; i < n-1; i++){

			if(shiva[i] == 28 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 29 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 30 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 31){
				if(i != 0 && shiva[i-1] == 31 && shiva[i+1] == 31){
					fair = false;
				}

				if(i != 0 && shiva[i-1] != 31){ // precondition fix for before and after feb, find howmany months there are
					if(shiva[i+1] == 28 || shiva[i+1] == 29)
						fair = false;
				}

				if(i == 0 && shiva[i+1] != 31 && shiva[i+1] != 30 && shiva[i+1] != 29 && shiva[i+1] != 28)
					fair = false;
			}
			if(thirty1 == false || thirty == false || twenties == false && i>=11){
				fair = false;
			}
			if(leaped == true && shiva[i] == 29)
				fair = false;

			if(shiva[i] == 29){
				leaped = true;
			}
		}

		if(fair == false){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}

	}
}

import java.io.*;
//import java.lang.reflect.Array;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class citylights {
    public static int[] arr;
    public static ArrayList<Integer> p;
    public static int[] val;
    public static long[] facto;
    public static long mod = 1000000007;
    public static long[] fillme;
    public static int ans = 0;
    public static int n, k;
    public static int [][]a;
    public static int []cnt=new int[27];
    static InputReader in;
    static PrintWriter out;
    public static HashSet<Long> hs=new HashSet<>();
    public static ArrayList<Integer> ar[];
    public static long x,y;
    public static long MOD= (long) (1e9+7);
    public static boolean []v;
    public static int []cal = {31,28,31,30,31,30,31,31,30,31,30,31};

//--------------------------------------My Code--------------------------------------------

    public static void main(String[] args) throws IOException {
        //arr = new int[1000001];
        //  p = new ArrayList<>();
        //  val = new int[1000001];
        // facto = new long[10000007];
        //tt=new int[100];
        //sieve();
        //  fact();
        //  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        InputReader in=new InputReader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        //Scanner in=new Scanner(System.in);

        int []curr = new int[60];

        int n =in.nextInt();
        for (int i=0;i<n;i++)
        {
            curr[i] = in.nextInt();
        }

        for (int year = 1000 ; year<=40000 ; year++)
        {
            int current = year;
            for (int i = 0 ;i<12;i++)
            {
                int m = i;
                boolean checker = false;
                for (int j = 0;j<n;j++)
                {
                    if(monthwala(current,m)!=curr[j])
                    {
                        checker = true;
                        break;
                    }
                    m++;
                    if(m==12)
                    {
                       m = 0;
                       current++;
                    }

                }
                if(!checker)
                {
                    out.println("Yes");
                    out.close();
                    return;
                }

            }
        }
        out.println("No");

        out.close();
    }

    static int monthwala(int year , int month)
    {
        if(month!=1)return cal[month];
        else if((year % 400 == 0) ||(year%4==0 && year%100!=0))return 28;
        else return 29;
    }
    //-------------------------------------------Code ends-------------------------------
static class people{
        String name;
        int region;
        int point;

        public people(String name, int region, int point) {
            this.name = name;
            this.region = region;
            this.point = point;
        }
    }
 static long getFactorial(long number) {
        long factorial = 1;
        for (long i = 1; i <= number; ++i) {
            factorial *= i;
        }
        return factorial;
    }
    public static void primeFactors(long n)
    {
        // Print the number of 2s that divide n
        while (n%2==0)
        {
           hs.add((long) 2);
            n /= 2;
        }
        long k= (long) Math.sqrt(n);
        for (int i = 3; i <= k; i+= 2)
        {
            while (n%i == 0)
            {
                hs.add((long) i);
                n /= i;
            }
        }
        if (n > 2)
            hs.add(n);
    }

    public static long bsearchg(int[] a, int t) {
        long ans = 0;
        int low = 0;
        int high = a.length - 1;
        while (low <= high) {
            int mid = (low + high) / 2;
            if (a[mid] <= t) {
                ans = mid;

                low = mid + 1;
            } else
                high = mid - 1;

        }
        return ans;

    }

    private static long fib(long n) {
        if (n == 1) return y;
        if (n == 0) return x;
        long[][] F = new long[][]{{1, -1}, {1, 0}};
        matPow(F, n);
        return F[0][0];
        //return 0l;
    }

    private static void matPow(long[][] F, long n) {
        if (n == 0 || n == 1)
            return;
        long M[][] = new long[][]{{1, -1}, {1, 0}};

        matPow(F, n / 2);
        matrixMult(F, F);

        if (n % 2 != 0)
            matrixMult(F, M);
    }

    public static long MOD(long x,long y)
    {
        long xk=x;
        long yk=y;
        if(xk<0)
        {
           xk+=mod;
        }if(yk<0)
        {
            yk+=mod;
        }
        return (xk+yk)%mod;

    }
    private static void matrixMult(long A[][], long M[][]) {
        long a = MOD((A[0][0] * M[0][0]) %mod, (A[0][1] * M[1][0])%mod) % mod;
        long b = MOD((A[0][0] * M[0][1])%mod , (A[0][1] * M[1][1])%mod) % mod;
        long c = MOD((A[1][0] * M[0][0])%mod, (A[1][1] * M[1][0])%mod) % mod;
        long d = MOD((A[1][0] * M[0][1])%mod, (A[1][1] * M[1][1])%mod)% mod;

        A[0][0] = a;
        A[0][1] = b;
        A[1][0] = c;
        A[1][1] = d;
    }

    private static long lcm(long a, long b) {
        return (long) ((a * b) / euclgcd(a, b));
    }

    public static int[] rotate(int[] order, int by) {
        int length = order.length;
        int[] a = new int[length];
        for (int i = 0; i < length; i++) {
            a[(i + by) % length] = order[i];

        }
        return a;

    }

    public static long modinv(long x, long m) {
        return powmod(x, m - 2, m);

    }

    public static long eulertoitent(long n) {
        long res = n;
        for (int i = 2; i * i <= n; i++)
            if (n % i == 0) {
                while (n % i == 0)
                    n /= i;
                res -= res / i;
            }
        if (n > 1)
            res -= res / n;
        return res;

    }

    //calculate factorial till modulas
    public static void fact() {
        facto[0] = 1;
        for (int i = 1; i <= mod; i++) {
            facto[i] = (i * facto[i - 1]) % mod;
        }

    }

    public static void sieve() {
        arr[0] = 1;
        arr[1] = 1;

        for (int i = 2; i * i < 1000001; i++) {
            if (arr[i] == 0) {

                for (int j = i * i; j < 1000001; j += i) {
                    arr[j] = 1;
                }
            }
        }
        for (int i = 2; i < 1000001; i++) {
            if (arr[i] == 0)
                p.add(i);
        }
    }

    public static boolean isPrime(int n) {
        // Corner cases
        if (n <= 1) return false;
        if (n <= 3) return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n % 2 == 0 || n % 3 == 0) return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

    public static long euclgcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return euclgcd(b, a % b);

    }

    public static long powmod(long x, long n, long m) {
        long result = 1L;
        while (n > 0) {
            if (n % 2 == 1)
                result = (result * x) % m;
            x = (x * x) % m;
            n = n / 2;
        }

        return result;
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}

import java.util.Scanner;

public class months {

	public static void main(String[] args) {
		String normalMonths = "31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 ";
		String notNormalMonths = "31 29 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 ";
		String notaNormalMonths = "31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 ";
		String notrNormalMonths = "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 numberOfMonthes = 0;
		String myMonths = new String();
		Scanner sc= new Scanner(System.in);
		numberOfMonthes = sc.nextInt();

		for (int i = 0; i < numberOfMonthes; i++) {
			myMonths += sc.nextInt() + " ";
		}
		if(normalMonths.indexOf(myMonths) > -1 || notNormalMonths.indexOf(myMonths) > -1 || notaNormalMonths.indexOf(myMonths) > -1 || notrNormalMonths.indexOf(myMonths) > -1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int nonLeap[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int leap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            String posibleConfig[] = new String[4];

            for (int i = 0; i < 4; i++) {
                posibleConfig[i] = "";
            }
            for (int m : leap) {
                posibleConfig[0] += m + " ";
            }
            for (int m : nonLeap) {
                posibleConfig[0] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[0] += m + " ";
            }

            for (int m : nonLeap) {
                posibleConfig[1] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[1] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[1] += m + " ";
            }

            for (int m : leap) {
                posibleConfig[2] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[2] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[2] += m + " ";
            }

            for (int m : leap) {
                posibleConfig[3] += m + " ";
            }
            for (int m : leap) {
                posibleConfig[3] += m + " ";
            }
            for (int m : nonLeap) {
                posibleConfig[3] += m + " ";
            }
            int n = in.nextInt();
            String config = "";
            for (int i = 0; i < n; i++) {
                config += in.nextInt() + " ";
            }
            for (String posConfig : posibleConfig) {
                if (posConfig.indexOf(config) != -1) {
                    out.println("YES");
                    return;
                }
            }
            out.println("NO");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ignored) {

            }
        }

        public boolean readLine() {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                return false;
            }
            return true;
        }

        public int nextInt() {
            if (!st.hasMoreTokens()) readLine();
            return Integer.parseInt(st.nextToken());
        }

    }
}

import java.util.*;
import java.lang.*;
import java.math.*;

public class CF572A {
    public static int[] months =
    {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};
    public static void main(String[] args) {
        Scanner io = new Scanner(System.in);
        int N = io.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = io.nextInt();
        Integer[] ocs = occurences(A[0]);
        boolean found = false, flag = true;
        for(int i = 0; i < ocs.length; i++) {
            int coi = ocs[i];
            for(int j = 0; j < A.length; j++) {
                if(coi+j > months.length - 1 || months[coi+j] != A[j])
                    break;
                if(j == A.length-1) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    public static Integer[] occurences(int elem) {
        ArrayList<Integer> oc = new ArrayList<Integer>();
        for(int i = 0; i < months.length; i++)
            if(elem == months[i])
                oc.add(i);
        Integer[] occurences = new Integer[oc.size()];
        oc.toArray(occurences);
        return occurences;
    }

}

import java.io.*;
import java.util.*;
public class B
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        String p1="31 28 31 30 31 30 31 31 30 31 30 31";
        String p2="31 29 31 30 31 30 31 31 30 31 30 31";
        p1=p1+" "+p1+" "+p1+" "+p1;
        p2=p2+" "+p2+" "+p2+" "+p2;
        String in=br.readLine();
        boolean bool=(p1.indexOf(in)!=-1 || p2.indexOf(in)!=-1);
        System.out.println(bool ? "YES" : "NO");
    }
}

import java.util.Scanner;

/**
 * Created by makarfi on 12/17/17.
 */
public class B {
    static int[] months = new int[]{31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};// dec - nov
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) a[i] = in.nextInt();

        int pos = 0, turns = 0;
        boolean leapYear = false;
        for (int i = 0; i < months.length && pos < n && turns < 100; i = (i+1)%12, turns++) {
            if (((a[pos] == 28 || a[pos] == 29) && i == 2)) {
                if (a[pos] == 29 && !leapYear) {
                    leapYear = true;
                } else if (a[pos] == 29 && leapYear) {
                    pos = 0;
                }
                pos++;
            } else if (months[i] == a[pos]) {
                pos++;
            } else {
                pos = 0;
            }
        }

        System.out.println(pos == n ? "YES" : "NO");
    }
}

import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int [] a = {31,28,31,30,31,30,31,31,30,31,30,31};
		int [] b = {31,29,31,30,31,30,31,31,30,31,30,31};

		int n = sc.nextInt();
		int [] arr = new int[n];
		for (int i =0;i<n;i++)
		{
			arr[i] = sc.nextInt();
		}

		int [] temp = new int[36];

		boolean truth = false;

		for (int i =0;i<12;i++)
			temp[i] = a[i];
		for (int i =12;i<24;i++)
			temp[i] = a[i-12];
		for (int i =24;i<36;i++)
			temp[i] = a[i-24];

		 truth = check(arr,temp);

		 if (truth)
			 System.out.println("YES");
		 else
		 {
			 for (int i =0;i<12;i++)
				temp[i] = a[i];
			 for (int i =12;i<24;i++)
				temp[i] = b[i-12];
			 for (int i =24;i<36;i++)
				temp[i] = a[i-24];

			 truth = check(arr,temp);

			 if (truth)
				 System.out.println("YES");
			 else
			 {
				 for (int i =0;i<12;i++)
						temp[i] = b[i];
					 for (int i =12;i<24;i++)
						temp[i] = a[i-12];
					 for (int i =24;i<36;i++)
						temp[i] = a[i-24];

					 truth = check(arr,temp);

					 if (truth)
						 System.out.println("YES");
					 else
						 System.out.println("NO");

			 }

		 }

		sc.close();
	}

	public static boolean check(int [] arr, int [] t)
	{
		boolean flag = true;
		for (int i =0;i<36-arr.length;i++)
		{

			if (t[i]==arr[0])
			{
				for (int j = 1;j<arr.length;j++)
				{
					//System.out.println(arr[j]+" "+t[i+j]);
					if (arr[j]!=t[i+j])
					{
						flag=false;
						break;
					}
				}
				//System.out.println(flag);
				if (flag)
					return true;
				flag=true;
			}

		}
		return false;
	}

}

import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final int[] Months=new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
    public static void main(String[] arg){
        Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        while(in.hasNext()){
            int n=in.nextInt();
            ArrayList<Integer> vec=new ArrayList<>();
            for(int i=0;i<n;i++){
                vec.add(in.nextInt());
            }
            boolean result=false;
            for(int i=0;i<Months.length && !result ;i++){
                if(vec.get(0)==Months[i] || vec.get(0)== 29){
                    boolean isLoop=false;
                    for(int j=0,start=i;j<n;j++){
                        if(vec.get(j) == Months[start] || vec.get(j)==29 && start == 1 && !isLoop ){
                            start = (start+1) % Months.length;
                            isLoop = vec.get(j) == 29 && start == 1;
                        }else{
                            break;
                        }
                        if(j==n-1){
                            result = true;
                        }
                    }
                }
            }
            out.println(result?"Yes":"No");
            out.flush();
        }
        in.close(); out.close();
    }
}

import java.util.Scanner;

public class SplittingIntoTeams {
	public static void main(String args[]){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int[] shiva = new int[n];
		boolean fair = true;
		boolean leaped = false;
		for(int i = 0; i < n; i++){
			shiva[i] = input.nextInt();
		}

		for(int i = 0; i < n-1; i++){
			if(shiva[i] == 28 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 29 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 30 && shiva[i+1] != 31){
				fair = false;
			}else if(shiva[i] == 31){
				if(i != 0 && shiva[i-1] == 31 && shiva[i+1] == 31){
					fair = false;
				}

				if(i != 0 && shiva[i-1] != 31){ // precondition fix for before and after feb, find howmany months there are
					if(shiva[i+1] == 28 || shiva[i+1] == 29)
						fair = false;
				}

				if(i == 0 && shiva[i+1] != 31 && shiva[i+1] != 30 && shiva[i+1] != 29 && shiva[i+1] != 28)
					fair = false;
			}

			if(leaped = true)
				fair = false;

			if(shiva[i] == 29){
				leaped = true;
			}
		}

		if(fair == false){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}

	}
}

import java.util.HashSet;
import java.util.Scanner;

public class B {

	static int[] poss = new int[40];

	static HashSet<Integer> odd = new HashSet<Integer>();
	static HashSet<Integer> even = new HashSet<Integer>();

	public static void main(String[] args) {

		poss[0] = 31;
		poss[1] = 28;
		poss[2] = 31;
		poss[3] = 30;
		poss[4] = 31;
		poss[5] = 30;
		poss[6] = 31;
		poss[7] = 31;
		poss[8] = 30;
		poss[9] = 31;
		poss[10] = 30;
		poss[11] = 31;

		int p = 12;
		poss[0 + p] = 31;
		poss[1+ p] = 29;
		poss[2+ p] = 31;
		poss[3+ p] = 30;
		poss[4+ p] = 31;
		poss[5+ p] = 30;
		poss[6+ p] = 31;
		poss[7+ p] = 31;
		poss[8+ p] = 30;
		poss[9+ p] = 31;
		poss[10+ p] = 30;
		poss[11+ p] = 31;

		poss[0 + 2*p] = 31;
		poss[1+ 2*p] = 28;
		poss[2+ 2*p] = 31;
		poss[3+ 2*p] = 30;
		poss[4+ 2*p] = 31;
		poss[5+ 2*p] = 30;
		poss[6+ 2*p] = 31;
		poss[7+ 2*p] = 31;
		poss[8+ 2*p] = 30;
		poss[9+ 2*p] = 31;
		poss[10+ 2*p] = 30;
		poss[11+ 2*p] = 31;

		poss[36] = 31;
		poss[37] = 28;
		poss[38] = 31;
		poss[39] = 30;

		for(int i = 0; i < 12; ++i) {
			if(i <= 6) {
				if(i%2 == 0) { odd.add(i) ; odd.add(i+12); odd.add(i+24);}
				else if(i!=1){ even.add(i); even.add(i+12); even.add(i+24);}
			}
			else {
				if(i%2 == 1) { odd.add(i); odd.add(i+12); odd.add(i+24);}
				else { even.add(i); even.add(i+12); even.add(i+24); }
			}
		}

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();

		int mon[] = new int[n];

		for(int i = 0; i < n; ++i) mon[i] = in.nextInt();

		check(mon);

		in.close();
	}

	static void check(int[] a) {
		if(a[0] == 31) {
			for(Integer index: odd) {
				boolean found = true;
				int count = 0;
				for(int i = index; i < Math.min(poss.length, a.length+index); ++i) {
					count++;
					if(a[i-index] != poss[i]) {
						found = false;
						break;
					}
				}
				if(found && count == a.length)  {
					System.out.println("YES");
					return;
				}
			}
		}
		else if(a[0] == 30) {
			for(Integer index: even) {
				boolean found = true;
				int count = 0;
				for(int i = index; i < Math.min(poss.length, a.length+index); ++i) {
					count++;
					if(a[i-index] != poss[i]) {
						found = false;
						break;
					}
				}
				if(found && count == a.length)  {
					System.out.println("YES");
					return;
				}
			}
		}
		else if(a[0] == 28) {
			boolean found = true;
			int count = 0;
			for(int i = 1; i < Math.min(poss.length, a.length+1); ++i) {
				count++;
				if(a[i-1] != poss[i]) {
					found = false;
					break;
				}
			}
			if(found && count == a.length)  {
				System.out.println("YES");
				return;
			}
		}

		else {
			boolean found = true;
			int count = 0;
			for(int i = 13; i < Math.min(poss.length, a.length+13); ++i) {
				count++;
				if(a[i-13] != poss[i]) {
					found = false;
					break;
				}
			}
			if(found && count == a.length)  {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
		return;
	}

}

import java.io.File;
import java.io.FileNotFoundException;
    import java.util.*;
import javafx.util.Pair;

   public class Main {

    public static void main(String[] args) throws FileNotFoundException{
//        File f = new File("input.txt");
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String s1 = "312831303130313130313031312831303130313130313031";
        String s2 = "312931303130313130313031312831303130313130313031";
        String check="";
        for (int i = 0; i < n; i++) {
            check+=input.nextInt();
        }
        if(s1.contains(check))
        {
            System.out.println("YES");
        }
        else if(s2.contains(check))
        {
            System.out.println("YES");
        }
        else
            System.out.println("NO");

    }

}

import java.util.*;
public class Q2r
{
	public static void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int arr[]=new int[n];
		int pos1=-1,pos2=-1,i,f=0,temp=0;
        for(i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}
		for(i=0;i<n-1;i++)
		{
			if(((arr[i]==28||arr[i]==29)&&arr[i+1]==31))
			{   if(temp==arr[i])
				{f=1;

			    break;

				}
				pos1=i;
				temp=arr[i];
		        if(pos2!=-1&&((pos1-pos2-2)!=0))
				{
					f=1;
					break;
				}
			}
		else if(arr[i]==31&&arr[i+1]==31)
		{
			if(pos1!=-1&&(i-pos1)!=5)
			{
				f=1;
				break;
			}
			else if(pos2!=-1&&((i-pos2-5)!=0&&(i-pos2-7)!=0))
			{		System.out.println(i);

				f=1;
		     break;
			}
			pos2=i;
			pos1=-1;

		}
		else if((arr[i]==31&&arr[i+1]==30)||(arr[i]==30&&arr[i+1]==31)||(arr[i]==31&&(arr[i+1]==28||arr[i+1]==29)))
		{
		}
		else
		{f=1;

		}
		}
		if(pos2==-1&&pos1==-1&&n>9)
		{
			f=1;
		}

		if(f==0)
		System.out.println("Yes");
       	else
		System.out.println("No");
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class year {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int n=Integer.parseInt(bf.readLine());
        String ly="31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31";
              ly+="31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30";
              ly+="31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30";
        String in=bf.readLine(),flag="NO";
        if (ly.contains(in) ) {
            flag="YES";
        }
        out.write(flag+"\n");
        out.flush();
    }
}

import java.util.*;
import java.io.*;

public class B
{

    Reader in;
    PrintWriter out;
    int i = 0, j = 0;
    void solve()
    {

        //START//
        int days[]={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};
        ArrayList<Integer> dl = new ArrayList<Integer>();
        for (i = 0; i < days.length; i++)
            dl.add((Integer)days[i]);
        ArrayList<Integer> inp = new ArrayList<Integer>();
        int n = in.nextInt();
        for (i = 0; i < n; i++)
        {
            int x = in.nextInt();
            inp.add((Integer)x);
        }
        if (Collections.indexOfSubList(dl, inp) == -1)
        {
            out.println("No");
        }
        else
            out.println("Yes");

        //END

    }
    void runIO()
    {
        in = new Reader();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args)
    {
        new B().runIO();
    }

    // input/output
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);

            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public final String next()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt()
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong()
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.')
                while ((c = read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);
            if (neg)
                return -ret;
            return ret;
        }

        public int[] readIntArray(int size)
        {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public long[] readLongArray(int size)
        {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        private void fillBuffer()
        {
            try
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            }
            catch (IOException e)
            {

            }

            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read()
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
    }
}

import java.util.*;
import java.io.IOException;

public class Test {
    int readInt() {
        int ans = 0;
        boolean neg = false;
        try {
            boolean start = false;
            for (int c = 0; (c = System.in.read()) != -1; ) {
                if (c == '-') {
                    start = true;
                    neg = true;
                    continue;
                } else if (c >= '0' && c <= '9') {
                    start = true;
                    ans = ans * 10 + c - '0';
                } else if (start) break;
            }
        } catch (IOException e) {
        }
        return neg ? -ans : ans;
    }

    int[] days = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    void start() {
        int n = readInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) d[i] = readInt();
        boolean found = false;
        for (int leap = 0; leap <= 1; leap++) {
            loop:
            for (int i = 0; i < 12; i++) {
                boolean meet2 = false;
                for (int j = 0; j < n; j++) {
                    int t = (i + j) % 12;
                    int td = days[t];
                    if (t == 1) {
                        if (!meet2) {
                            td += leap;
                            meet2 = true;
                        }
                        if (d[j] != td) {
                            if (meet2) {
                                if (leap == 0) {
                                    if (d[j] != td + 1) continue loop;
                                }
                            }
                        }
                    }
                    if (d[j] != td) continue loop;
                }
                found = true;
            }
            if (found) break;
        }
        System.out.println(found ? "YES" : "NO");
    }

    public static void main(String[] args) {
        new Test().start();

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        try (PrintWriter or = new PrintWriter(System.out)) {
            int n = in.nextInt();
            String s = "";
            String demo = "312831303130313130313031";
            String demo2 = "312931303130313130313031";
            while (n-- > 0) s += in.nextInt() + "";
            if (demo.contains(s)||demo2.contains(s))or.println("Yes");
            else or.println("No");

        }

    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++) {
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec) {
                        f *= 10;
                    }
                }
            }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }

}

class Pair8 {

    int from;
    int to;

    // int min;
    public Pair8(int from, int to) {

        this.from = from;
        this.to = to;
        //min = m;
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskBcale solver = new TaskBcale();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskBcale {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int arr[] = in.nextIntArray(n);
            int a1[] = {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 a2[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int j = -1, flag = 0;
            l:
            while (j < a1.length - 1) {
                j++;
                if (arr[0] == a1[j]) {
                    flag = 0;
                    int k = j;
                    for (int i = 0; i < arr.length; i++) {
                        if (k > a1.length - 1) {
                            flag = 1;
                            break l;
                        }
                        if (arr[i] != a1[k]) {
                            flag = 1;
                            break;
                        }
                        k++;
                    }
                    if (flag == 0) {
                        out.println("YES");
                        return;
                    }
                }
            }
            j = -1;
            flag = 0;
            l1:
            while (j < a2.length - 1) {
                j++;
                if (arr[0] == a2[j]) {
                    flag = 0;
                    int k = j;
                    for (int i = 0; i < arr.length; i++) {
                        if (k > a2.length - 1) {
                            flag = 1;
                            break l1;
                        }
                        if (arr[i] != a2[k]) {
                            flag = 1;
                            break;
                        }
                        k++;
                    }
                    if (flag == 0) {
                        out.println("YES");
                        return;
                    }
                }
            }
            out.println("NO");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; ++i) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = readInt();
        int[] a = readIntArray(n);
        int[] arr = {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};
        n = arr.length;
        boolean flag;
        for (int i = 0; i < n - a.length; i++) {
            flag = true;
            for (int j = 0; j < a.length; j++) {
                if (arr[i + j] != a[j]) flag = false;
            }
            if (flag) {
                out.println("Yes");
                return;
            }
        }
        out.println("No");
    }

    int checkBit(int mask, int bit) {
        return (mask >> bit) & 1;
    }

    public static void main(String[] args) throws IOException {

        new Main().run();
    }

    boolean isLower(char a) {
        return ((int) a) >= 97 ? true : false;
    }

    int INF = Integer.MAX_VALUE / 10;

    int[][] STEPS = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    Random rnd = new Random();
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    Main() throws FileNotFoundException {

        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        tok = new StringTokenizer("");
    }

    long checkBit(long mask, int bit) {
        return (mask >> bit) & 1;
    }

    void run() throws IOException {
        solve();
        out.close();
    }

    char varChar;
    int varInt, varInt1, varInt2;
    long varLong;

    long sqrt(long m) {
        long l = 0;
        long r = m;
        long answer = 0;
        long mid = 0;
        while (l <= r) {
            mid = (l + r) / 2;
            if (mid * mid <= m) {
                answer = mid;
                l = mid + 1;
            } else r = mid - 1;
        }
        return answer;
    }

    int countPow(int m, int n) {
        varInt = 0;
        while (m % n == 0 && m > 0) {
            varInt++;
            m /= n;
        }
        return varInt;
    }

    long binPow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return a * binPow(a, b - 1);
        } else {
            varLong = binPow(a, b / 2);
            return varLong * varLong;
        }

    }

    int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    long pow(long x, long k) {
        varLong = 1;
        for (int i = 0; i < k; ++i) {
            varLong *= x;
        }
        return varLong;
    }

    class Fenwik {
        private long[] t;
        private int length;

        Fenwik(int[] a) {
            this.length = a.length + 100;
            this.t = new long[length];
            for (int i = 0; i < a.length; ++i) {
                this.inc(i, a[i]);
            }
        }

        void inc(int i, int delta) {
            for (; i < this.length; i = i | (i + 1)) {
                this.t[i] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;

            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += this.t[r];
            }

            return sum;
        }

    }

    // ////////////////////////////////////////////////////////////////////

    String delimiter = " ";

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine)
                return null;

            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken(delimiter);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int b) {
        int a[] = new int[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = readInt();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }

    int[] readSortedIntArray(int size) throws IOException {
        Integer[] array = new Integer[size];

        for (int index = 0; index < size; ++index) {
            array[index] = readInt();
        }
        Arrays.sort(array);

        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) {
            sortedArray[index] = array[index];
        }

        return sortedArray;
    }

    int[] sortedIntArray(int size, int[] array) throws IOException {
        for (int index = 0; index < size; ++index) {
            array[index] = readInt();
        }
        Arrays.sort(array);

        int[] sortedArray = new int[size];
        for (int index = 0; index < size; ++index) {
            sortedArray[index] = array[index];
        }

        return sortedArray;
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    long minLong(long... values) {
        long min = Long.MAX_VALUE;
        for (long value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    long maxLong(long... values) {
        long max = Long.MIN_VALUE;
        for (long value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    boolean checkIndex(int index, int size) {
        return (0 <= index && index < size);
    }

    int abs(int a) {
        return Math.abs(a);
    }
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class B {
	static boolean compare(String str[], List<String> list) {
		for (int i = 0; i < str.length; ++i)
			if (!str[i].equals(list.get(i)))
				return false;
		return true;
	}

	public static void main(String[] args) {
		Scanner jin = new Scanner(System.in);

		String leap[] = { "31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" };
		String norm[] = { "31", "29", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" };

		int n = jin.nextInt();

		String[] list = new String[n];

		for (int i = 0; i < n; ++i)
			list[i] = jin.nextInt() + "";

		ArrayList<String> generatedLeap = new ArrayList<String>();
		ArrayList<String> generatedNorm = new ArrayList<String>();

		for (int i = 0; i < n + 12; ++i) {
			generatedLeap.add(leap[i % 12]);
			generatedNorm.add(norm[i % 12]);
		}

		if (generatedLeap.indexOf("28") != generatedLeap.lastIndexOf("28")) {
			int index = generatedLeap.lastIndexOf("28");
			generatedLeap.set(index, "29");

			index = generatedNorm.lastIndexOf("29");
			generatedNorm.set(index, "28");
		}

		for (int i = 0; i < generatedLeap.size(); ++i) {
			if (i + n > generatedLeap.size())
				break;
			else {
				List<String> subList = generatedLeap.subList(i, i + n);
				if (compare(list, subList)) {
					System.out.println("Yes");
					return;
				}
				subList = generatedNorm.subList(i, i + n);
				if (compare(list, subList)) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");

	}
}

import java.util.Scanner;

public class pro_452B {
    public static void main(String[] args) {
        int n ,a = 28 ,i ,j ,k = 0;
        Scanner scn = new Scanner(System.in);
        n = scn.nextInt();
        int[] arr = new int[n];
        for(i=0 ;i<n ;i++){
            arr[i] = scn.nextInt();
            if(arr[i] == 29) a = 29;
        }
        int[] month = {31 ,a ,31 ,30 ,31 ,30 ,31 ,31 ,30 ,31 ,30 ,31};
            for(j=0 ;j<12 ;j++){
                if(arr[0] == month[j]){
                    i = j+1;
                    for(k = 1 ;k<n ;k++){
                        if(arr[k] != month[i%12]) break;
                        i++;
                    }
                }
                if( k == n) {
                    System.out.println("YES");
                    break;
                }
            }
        if( j == 12) {
            System.out.println("NO");
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class B {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();

		ArrayList<Integer> leap = new ArrayList<>();
		leap.add(31);
		leap.add(29);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(31);
		leap.add(30);
		leap.add(31);
		leap.add(30);
		leap.add(31);

		ArrayList<Integer> nonLeap = new ArrayList<>();
		nonLeap.add(31);
		nonLeap.add(28);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);
		nonLeap.add(30);
		nonLeap.add(31);

		ArrayList<Integer> ans[] = new ArrayList[4];
		for (int i = 0; i < 4; i++)
			ans[i] = new ArrayList<>();
		ans[0].addAll(leap);
		ans[0].addAll(leap);
		ans[0].addAll(leap);

		ans[1].addAll(leap);
		ans[1].addAll(leap);
		ans[1].addAll(nonLeap);

		ans[2].addAll(leap);
		ans[2].addAll(nonLeap);
		ans[2].addAll(leap);

		ans[3].addAll(nonLeap);
		ans[3].addAll(leap);
		ans[3].addAll(leap);
		boolean ok = false;
		for (int i = 0; i < 4; i++) {
			ArrayList<Integer> cur = ans[i];
			outer: for (int st = 0; st + n <= cur.size(); st++) {
				for (int j = 0; j < n; j++){
					if (cur.get(st + j) != arr[j]){
						continue outer;
					}
				}
				ok = true;
			}
		}
		System.out.println(ok ? "YES" : "NO");
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}
	}
}

import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class SPOJANDCC
{
	@SuppressWarnings("rawtypes")
	static InputReader in;
	static PrintWriter out;

	static void solve()
	{
		int arr[] = new int[200 * 12];
		arr[0] = 31;
		arr[1] = 28;
		arr[2] = 31;
		arr[3] = 30;
		arr[4] = 31;
		arr[5] = 30;
		arr[6] = 31;
		arr[7] = 31;
		arr[8] = 30;
		arr[9] = 31;
		arr[10] = 30;
		arr[11] = 31;
		for (int i = 12; i < 24; i++)
			arr[i] = arr[i - 12];
		arr[13]++;
		for (int i = 24; i < 48; i++)
			arr[i] = arr[i - 24];
		int n = in.ni();
		int a[] = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.ni();
		for (int i = 0; i < 100; i++)
		{
			boolean u = true;
			for (int j = i; j < i + n; j++)
			{
				if (arr[j] != a[j - i])
				{
					u = false;
					break;
				}
			}
			if (u)
			{
				out.println("Yes");
				return;
			}
		}
		out.println("No");
	}

	@SuppressWarnings("rawtypes")
	static void soln()
	{
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args)
	{
		new Thread(null, new Runnable()
		{
			public void run()
			{
				try
				{
					soln();
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	static class InputReader<SpaceCharFilter>
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = ni();
			}
			return a;
		}

		public long[] nextLongArray(int n)
		{
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nl();
			}
			return a;
		}

		public String readString()
		{
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}

	}
}

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int t=Integer.parseInt(br.readLine());
    // while(t-->0)

      String query=br.readLine();
      String s="31 28 31 30 31 30 31 31 30 31 30 31";
      s=s+s;
      s=s+s;
      String w="31 29 31 30 31 30 31 31 30 31 30 31";
      w=w+w;
      w=w+w;
      if(s.contains(query))
        System.out.println("YES");
      else
      {
        if(w.contains(query))
        System.out.println("YES");
        else
        System.out.println("NO");

      }
   }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		// Scanner reader = new Scanner(System.in);
		InputReader reader = new InputReader();
		int n = reader.nextInt();
		StringBuilder check = new StringBuilder();
		String a = "312831303130313130313031312831303130313130313031312831303130313130313031";
		String b = "312931303130313130313031312931303130313130313031312931303130313130313031";
		String c = "312931303130313130313031312831303130313130313031312931303130313130313031";
		String d = "312831303130313130313031312931303130313130313031312831303130313130313031";
		// 312831303130313130313031
		// 31 28 31 30 31 30 31 31 30 31 30 31
		for (int i = 0; i < n; i++) {
			check.append(reader.next());
		}
		if (a.contains(check) || b.contains(check) || c.contains(check) || d.contains(check)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}

class InputReader {
	BufferedReader buf;
	StringTokenizer tok;

	InputReader() {
		buf = new BufferedReader(new InputStreamReader(System.in));
	}

	boolean hasNext() {
		while (tok == null || !tok.hasMoreElements()) {
			try {
				tok = new StringTokenizer(buf.readLine());
			} catch (Exception e) {
				return false;
			}
		}
		return true;
	}

	String next() {
		if (hasNext())
			return tok.nextToken();
		return null;
	}

	char nextChar() {
		return next().charAt(0);
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	/*
	 * BigInteger nextBigInteger() { return new BigInteger(next()); }
	 *
	 * BigDecimal nextBigDecimal() { return new BigDecimal(next()); }
	 */
}

import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    static int[] days =
        new int[]{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, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int consecutive = 0;
        boolean include = false;
        int start = 0;
        for (int i = 0; i < days.length; i++) {
            if (days[i] == a[i - start]) {
                consecutive++;
                if (consecutive == n) {
                    include = true;
                    break;
                }
            } else {
                start = i + 1;
                if (consecutive != 0) {
                    start = i;
                    consecutive = 0;
                    i--;
                }
            }
        }
        System.out.println(include ? "YES" : "NO");

    }
}

import java.util.*;
import java.lang.*;
import java.math.*;

public class CF572A {
    public static int[] months =
    {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};
    public static void main(String[] args) {
        Scanner io = new Scanner(System.in);
        int N = io.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = io.nextInt();
        Integer[] ocs = occurences(A[0]);
        boolean found = false, flag = true;
        for(int i = 0; i < ocs.length; i++) {
            int coi = ocs[i];
            for(int j = 0; j < A.length; j++) {
                if(coi+j > months.length - 1 || months[coi+j] != A[j])
                    break;
                if(j == A.length-1) {
                    System.out.println("YES");
                    return;
                }
            }
        }
        System.out.println("NO");
    }

    public static Integer[] occurences(int elem) {
        ArrayList<Integer> oc = new ArrayList<Integer>();
        for(int i = 0; i < months.length; i++)
            if(elem == months[i])
                oc.add(i);
        Integer[] occurences = new Integer[oc.size()];
        oc.toArray(occurences);
        return occurences;
    }

}

import java.util.*;

public class YearMonth {

    public static void main(String[] args) {
        Scanner r = new Scanner(System.in);
        int n = r.nextInt();
        int[] yearl = new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
        int[] year = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        int[] input = new int[n];

        for(int i=0; i<n ; i++){
            input[i] = r.nextInt();
        }

        if(check(year, input, n) || check(yearl, input, n)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

    public static boolean check(int[] year, int[] input, int n){
        int lock = 0;
        int j=0;
        boolean b = false;
        boolean a = false;

        for(int i=0; i<12; i++){
            if(j == n){
                a = true;
                break;
            }
            if((year[i] == input[j]) && !b){
                j++;
                b = true;
                lock = i;
            }else if((year[i] == input[j]) && b){
                j++;
                b = true;
            }else if(b){
                b=false;
                j = 0;
                i = lock;
            }else{
                b=false;
                j = 0;
            }
        }
            return a;
    }

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class year {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        int n=Integer.parseInt(bf.readLine());
        String ly="31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31";
              ly+="31 29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31";
              ly+="31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30";
              ly+="31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30";
        String in=bf.readLine(),flag="NO";
        if (ly.contains(in) ) {
            flag="YES";
        }
        out.write(flag+"\n");
        out.flush();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Months_and_years solver = new Months_and_years();
        solver.solve(1, in, out);
        out.close();
    }

    static class Months_and_years {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int tempArr[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            //int leap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            int n = in.scanInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) arr[i] = in.scanInt();

            for (int i = 0; i < 12; i++) {
                int j = 0;
                int temp = i;
                int c = 0;
                while (j < n && (tempArr[temp] == arr[j] || arr[j] == 29)) {
                    if (arr[j] == 29) c++;
                    j++;
                    temp = (temp + 1) % 12;
                }

                if (j == n && c < 2) {
                    out.println("YES");
                    return;
                }
            }

            out.println("NO");

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                    ;
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

import java.io.File;
import java.io.FileNotFoundException;
    import java.util.*;
import javafx.util.Pair;

   public class Main {

    public static void main(String[] args) throws FileNotFoundException{
//        File f = new File("input.txt");
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String s1 = "312831303130313130313031312831303130313130313031312931303130313130313031312831303130313130313031";

        String check="";
        for (int i = 0; i < n; i++) {
            check+=input.nextInt();
        }
        if(s1.contains(check))
        {
            System.out.println("YES");
        }

        else
            System.out.println("NO");

    }

}

import java.io.*;
import java.util.*;
import java.math.*;
public class codeforces
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n= sc.nextInt();
        int arr[]=new int[n];
        int ones=0;
        int teams=0;
        int twos=0;
        int leap1=0;
        int leap2=0;
        String s="";
        for(int i = 0 ;i<n;i++)
        {
            arr[i]=sc.nextInt();
            s+=""+arr[i];
            if(arr[i]==28)
            leap1++;
            if(arr[i]==29)
            leap2++;
            else if(arr[i]!=30&&arr[i]!=31)
            {
                System.out.println("NO");
                System.exit(0);
            }
        }
        if(leap1>1||leap2>1)
        {
            System.out.println("NO");
            System.exit(0);
        }
        String years="312831303130313130313031312931303130313130313031312831303130313130313031312931303130313130313031312831303130313130313031312931303130313130313031312831303130313130313031312931303130313130313031";

        for(int i = 0 ;i<years.length()-s.length();i++)
        {
            if(years.substring(i,i+s.length()).equals(s))
            {
                System.out.println("YES");
                System.exit(0);
            }
        }

        System.out.println("NO");

    }
}