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
3
3
3
1
1
1
1
3
3
3
3
1
2
3
1
2
2
2
3
3
2
1
3
3
1
2
3
1
1
1
2
2
2
3
1
1
1
1
1
1
3
2
2
2
2
2
2
3
1
2
2
2
2
2
3
3
2
1
1
 3
3
2
2
 3
3
2
3
 2
3
3
 3
2
2
1
 5
1
1
2
2
3
 3
1
3
1
 3
1
1
3

YES
 NO
 NO
 NO
 YES
 NO
 YES
 YES
 NO
 NO
 NO
 YES
 NO
 NO
 YES
 YES
 YES
 NO
 YES
 YES
 NO
 NO
 NO
 NO
 NO
 YES
 YES
 YES
 NO
 NO
 NO
 YES
 NO
 NO
 NO

import java.io.*;
import java.util.*;
import java.math.*;
public
class TaskA{
    //static variable
    static final int mod = (int) 1e9 + 7;
    static final double eps = 1e-6;
    static final double pi = Math.PI;
    static final long inf = Long.MAX_VALUE / 2;



    BufferedReader br;
    void main1() throws IOException {
        br=new BufferedReader(new InputStreamReader(System.in));
        int t=ii();
        int[] a=new int[t];
        for (int i = 0; i <t ; i++) {
            a[i]=ii();
        }
        int flag=0;
        if(t>2) {
            for (int i = 2; i < t; i++) {
                if (!(a[i] == a[i - 1] && a[i - 1] == a[i - 2])) {
                    if (a[i]==a[i-2]) {
                        flag=1;
                        break;
                    }
                }
            }
        }
        else{
            if(t==1){
                if(a[0]==3)
                    flag=1;
            }
            else{
                if(a[0]==1 && a[1]==2){
                        flag=1;
                }
            }
        }

        if(flag==1)
            System.out.println("NO");
        else
            System.out.println("YES");



    }




















    //Main Method............................................................................................................
    public static void main(String[] args) throws IOException {new TaskA().main1();}
    //.......................................................................................................................

    //static class
    static class Pair{
        int key,value;
        Pair(int key,int value){
            this.key=key;
            this.value=value;
        }
        int Key(){
            return key;
        }
        int Value(){
            return value;
        }
    }
    //input method
    int[] iint() throws IOException{
        String line[]=br.readLine().split(" ");
        int[] a=new int[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Integer.parseInt(line[i]);
        }
        return a;
    }
    long[] ilong() throws IOException{
        String line[]=br.readLine().split(" ");
        long[] a=new long[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Long.parseLong(line[i]);
        }
        return a;
    }
    double[] idouble() throws IOException{
        String line[]=br.readLine().split(" ");
        double[] a=new double[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Long.parseLong(line[i]);
        }
        return a;
    }
    long li() throws IOException{

        return Long.parseLong(br.readLine());
    }
    int ii() throws IOException{

        return Integer.parseInt(br.readLine());
    }
    double di() throws IOException{
        return Double.parseDouble(br.readLine());
    }
    char ci() throws IOException{
        return (char)br.read();
    }
    String si() throws IOException{
        return br.readLine();
    }
    String[] isa() throws IOException{
        String at =si();
        return at.split(" ");
    }

    double[][] idm(int n, int m) throws IOException{
        double a[][] = new double[n][m];
        for (int i = 0; i < n; i++) {
            double[] temp=idouble();
            for (int j = 0; j < m; j++) a[i][j] = temp[j];
        }
        return a;
    }

    int[][] iim(int n, int m) throws IOException{
        int a[][] = new int[n][m];
        for (int i = 0; i < n; i++) {
            int[] temp=iint();
            for (int j = 0; j < m; j++) a[i][j] =temp[j];
        }
        return a;
    }
    long[][] ilm(int n, int m) throws IOException{
        long a[][] = new long[n][m];
        for (int i = 0; i < n; i++) {
            long[] temp=ilong();
            for (int j = 0; j < m; j++) a[i][j] =temp[j];
        }
        return a;
    }

}