Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.So they play with each other according to following rules:  Alex and Bob play the first game, and Carl is spectating;  When the game ends, the one who lost the game becomes the spectator in the next game, and the one who was spectating plays against the winner. Alex, Bob and Carl play in such a way that there are no draws.Today they have played n games, and for each of these games they remember who was the winner. They decided to make up a log of games describing who won each game. But now they doubt if the information in the log is correct, and they want to know if the situation described in the log they made up was possible (that is, no game is won by someone who is spectating if Alex, Bob and Carl play according to the rules). Help them to check it!

The first line contains one integer n (1 ≤ n ≤ 100) — the number of games Alex, Bob and Carl played. Then n lines follow, describing the game log. i-th line contains one integer ai (1 ≤ ai ≤ 3) which is equal to 1 if Alex won i-th game, to 2 if Bob won i-th game and 3 if Carl won i-th game.

Print YES if the situation described in the log was possible. Otherwise print NO.

NoteIn the first example the possible situation is:  Alex wins, Carl starts playing instead of Bob;  Alex wins, Bob replaces Carl;  Bob wins. The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.

import java.util.Scanner;

public class C893A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int[] st = new int[4];
		st[1] = st[2] = 1;
		while(t-- > 0) {
			int w = sc.nextInt();
			if(st[w] == 0) {
				System.out.println("NO");
				return;
			}
			for(int i = 1 ; i <= 3 ; i++)
				if(i != w)
					st[i] ^= 1;
		}
		System.out.println("YES");
		sc.close();
	}
}

import java.util.Scanner;

public class ChessForThree {

	public static void main(String[] args) {
		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 spictator = 3;
		int jo1 = 1;
		int jo2 = 2;
		int count = 0;
		int aux = 0 ;

		for(int i=0;i<n;i++){
			if(a[i] == jo1){
				aux = jo2;
				jo2 = spictator;
				spictator = aux;
			}else if(a[i] == jo2){
				aux = jo1;
				jo1 = spictator;
				spictator = aux;
			}
			else{
				System.out.println("NO");
				System.exit(0);
			}
		}

		System.out.println("YES");

	}

}

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ChessForThree {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int p1 = 1;
        int p2 = 2;
        int spec = 3;
        boolean poss = true;
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            if (p1 == a) {
                int temp = p2;
                p2 = spec;
                spec = temp;
            }
            else if (p2 == a) {
                int temp = p1;
                p1 = spec;
                spec = temp;
            }
            else {
                poss = false;
            }
        }
        out.println(poss ? "YES" : "NO");
        out.close();
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

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

public class CF893A {
	public static void main(String[] arg) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		solver.solve(1, in, out);
		out.close();

	}

	static class Solver {
		private void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();

			boolean a = true;
			boolean b = true;
			boolean c = false;

			boolean ans = true;

			for (int i = 0; i < n; i++) {
				int r = in.nextInt();
				if (a && b && (r == 1)) {
					a = true;
					b = false;
					c = true;
				} else if (a && b && (r == 2)) {
					a = false;
					b = true;
					c = true;
				} else if (b && c && (r == 2)) {
					a = true;
					b = true;
					c = false;
				} else if (b && c && (r == 3)) {
					a = true;
					b = false;
					c = true;
				} else if (a && c && (r == 3)) {
					a = false;
					b = true;
					c = true;
				} else if (a && c && (r == 1)) {
					a = true;
					b = true;
					c = false;
				} else {
					ans = false;
					out.println("NO");
					break;
				}
			}
			if (ans)
				out.println("YES");
		}
	}

	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.util.Scanner;

public class codeforces {

    public static void main(String[] args) {
        TaskA Solver = new TaskA();
        Solver.Solve();
    }

    public static class TaskA {
        public void Solve() {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int last = in.nextInt();
            int p1 = 0, p2 = 0, w = 0;
            boolean fl = true;
            if (last == 1) {
                p1 = 1;
                p2 = 3;
                w = 2;
            }
            else {
                if (last == 2) {
                    p1 = 2;
                    p2 = 3;
                    w = 1;
                }
                else
                    fl = false;
            }
            for (int i = 1; i < n; i++) {
                int cur = in.nextInt();
                if (cur == w)
                    fl = false;
                else {
                    if (cur == p1) {
                        p1 = cur;
                        int t = p2;
                        p2 = w;
                        w = t;
                    }
                    else {
                        p2 = cur;
                        int t = p1;
                        p1 = w;
                        w = t;
                    }
                }
            }
            System.out.println(fl ? "YES" : "NO");
        }
    }
}

import java.util.*;
public class Chess_Check {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int [] wins=new int[n];
		for(int i=0;i<n;i++) {
			wins[i]=in.nextInt();
		}
		boolean check=true;
		int spc=3;
		for(int i=0;i<n;i++) {
			if(spc==wins[i]) {
				check=false;
				break;
			}
			else {
				if(wins[i]==1) {
					if(spc==2) spc=3;
					else if(spc==3) spc=2;
				}
				else if(wins[i]==2) {
					if(spc==1) spc=3;
					else if(spc==3) spc=1;

				}
				else if(wins[i]==3) {
					if(spc==2) spc=1;
					else if(spc==1) spc=2;

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

}

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

public class Main {
    public void solve() throws IOException {
        int n = nextInt();
        boolean t = false;
        int[] a = new int[n];
        int x = 1;
        int y = 2;
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        boolean r = true;
        for(int i = 0; i < n; i++){
            int z = 6 - x - y;
            if(a[i] == x){
                y = z;
            }else {
                if(a[i] == y){
                    x = z;
                }else {
                    r = false;
                }
            }
        }
        if(r){
            t = true;
        }

        if(t){
            out.print("YES");
        }else {
            out.print("NO   ");
        }
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    public boolean hasNext() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    public Integer nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public Long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public Double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception e) {
        }
        new Main().run();
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("truth.in"));
//            out = new PrintWriter(new File("truth.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author school_olimp
 */
public class JVM {

    /**
     * @param args the command line arguments
     */
    static String[] dmitry_ivanovich;
    static String s;
    /**
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = 3;
        int p1 = 1;
        int p2 = 2;

        for(int i = 0; i < n; i++){
            int m = sc.nextInt();
            if(w == m) {
                System.out.println("NO");
                return;
            }
            else if (m == p1){
                int k = p2;
                p2 = w;
                w = k;
            }
            else{
                int k = p1;
                p1 = w;
                w = k;
            }
        }
        System.out.println("YES");
    }

}

//problem: https://codeforces.com/problemset/problem/893/A

import java.util.Scanner;

public class Chess3{
    public static void main(String[] args){
        Scanner sObj = new Scanner(System.in);
        int nos = Integer.parseInt(sObj.nextLine());
        int[] arr = new int[2];
        arr[0] = 1;
        arr[1] = 2;
        int spect = 3;
        int temp = 0;
        for(int i=0; i<nos; i++){
            temp = sObj.nextInt();
            if(temp == arr[0]){
                arr[1] += spect;
                spect =  arr[1] - spect;
                arr[1] -= spect;
                continue;
            }
            else if(temp == arr[1]){
                arr[0] += spect;
                spect =  arr[0] - spect;
                arr[0] -= spect;
                continue;
            }
            else{
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

import java.util.*;
public class ChessForThree

{
	public static void main(String[] args)
	{
		Scanner kb =  new Scanner(System.in);
		int n = kb.nextInt();
		int[] player = new int[n+1];
		for(int i = 1; i<=n; i++)
		{
			player[i] = kb.nextInt();

		}

		int a = 1;
		int b = 2;
		int c = 3;
		boolean f = true;
		int t;
		for(int i = 1; i<= n; i++)
		{
			if(player[i] == a)
			{
				t = b;
				b = c;
				c = t;
			}

			else if(player[i] == b)
			{
				t = a;
				a = c;
				c = t;
			}
			else
				f = false;

		}

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

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

public class Solution{
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	int n;
	int[] arr;
	public void solve(){
		n=ni();
		arr=na(n);

		boolean flag=false;
		TreeSet<Integer> ts=new TreeSet<Integer>();
		ts.add(1);
		ts.add(2);
		int i;
		for(i=1;i<=n;i++){
			if(!ts.contains(arr[i-1]))break;
			int sum=0;
			for(Integer itr: ts){
				sum=sum+itr;
			}
			ts.clear();
			ts.add(arr[i-1]);
			ts.add(6-sum);
		}
		if(i==n+1){
			flag=true;
		}

		if(flag==true)out.println("YES");
		else out.println("NO");
	}

	void run(){
		is = new DataInputStream(System.in);
		out = new PrintWriter(System.out);
		int t=1;while(t-->0)solve();
		out.flush();
	}
	public static void main(String[] args)throws Exception{new Solution().run();}
	//Fast I/O code is copied from uwi code.
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private int readByte(){
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	private String ns(){
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	private char[] ns(int n){
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	private char[][] nm(int n, int m){
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	private int[] na(int n){
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	private int ni(){
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	private long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	static  int i(long x){return (int)Math.round(x);}
	static class Pair implements Comparable<Pair>{
		long fs,sc;
		Pair(long a,long b){
			fs=a;sc=b;
		}
		public int compareTo(Pair p){
			if(this.fs>p.fs)return 1;
			else if(this.fs<p.fs)return -1;
			else{
				return i(this.sc-p.sc);
			}
			//return i(this.sc-p.sc);
		}
		public String toString(){
			return "("+fs+","+sc+")";
		}
	}

}

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

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int v = 3;
		String result = "YES";
		for(int i = 0; i < n; i++) {
			int w = in.nextInt();
			if(v != w)
				v = 6-w-v;
			else {
				result = "NO";
				break;
			}
		}
		System.out.println(result);

	}

}

import java.util.Scanner;
public class Codeforces
{
    public static void main(String[] args)
    {
      Scanner scan=new Scanner(System.in);
      int n=scan.nextInt();
      int[] arr=new int[n];
      int[] brr=new int[3];
      brr[0]=1;
      brr[1]=2;
      brr[2]=3;
      for(int i=0;i<n;i++)
      {
          arr[i]=scan.nextInt();
      }

        for(int i=0;i<n;i++)
        {
           if(arr[i]==brr[0])
           {
               int temp=brr[1];
               brr[1]=brr[2];
               brr[2]=temp;
           }
           else if(arr[i]==brr[1])
           {
               int temp=brr[0];
               brr[0]=brr[2];
               brr[2]=temp;
           }
           else
           {
               System.out.print("NO");
               System.exit(0);
           }
        }
        System.out.print("YES");

    }
}

import java.util.Scanner;

public class ChessForThree {

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

		int n = in.nextInt();
		int spec = 3;
		String possible = "YES";

		for(int i = 0; i < n; i++){
		int win = in.nextInt();

		if(win==spec){
			possible = "NO";
		}
		else
			spec = 6 - win - spec;

		}
		System.out.println(possible);

}
}

import java.util.*;

public class Main
{
	public static void main (String [] args)
	{

		Scanner sc = new Scanner(System.in);
		int spectator = 3;
		int total = sc.nextInt();
		for(int i = 0; i < total; i++)
		{
			int num = sc.nextInt();
			if(num == spectator)
			{
				System.out.println("NO");
				return;
			}
			else if(1 != spectator && 1 != num)
			{
				spectator = 1;
			}
			else if(2 != spectator && 2 != num)
			{
				spectator = 2;
			}
			else if(3 != spectator && 3 != num)
			{
				spectator = 3;
			}
		}
		System.out.println("YES");
	}
}

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

public class A {
    public static void main(String[] args){
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        int[] g = new int[n];
        for (int i = 0; i < n; i++) {
            g[i] = fr.nextInt();
        }
        int a = 1, b = 2, c = 3, f = 0;
        for (int i = 0; i < n; i++) {
            if(g[i]!=a&&g[i]!=b){
                f++;
                break;
            } else if (g[i]==a){
                int temp = b;
                b = c;
                c = temp;
            } else {
                int temp = a;
                a = c;
                c = temp;
            }
        }
        if(f==0){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
    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;
        }
    }
}

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

public class CodingLegacy {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindrome solver = new Palindrome();

        int t = 1;
//        t = in.nextInt();

        for (int i = 0; i < t; i++) {
            solver.solve(i + 1, in, out);
        }

        out.close();
    }

    static class Palindrome {
        static long mod = 1000000007;
        static long maxX = (long) 1e18;
        static long mod2 = 998244353;

        //  Check for boundary Condition because you are not Sehwag..
        //  For multiple Test cases take all input -> do not use return while taking input.
        //  at least check constraint for once it can be done in nested loops.
        // Think simple and short
        //  check for proof of solution
        //  Read editorial after contest.....

        void solve(int testNumber, ScanReader in, PrintWriter out) {

            int n = in.nextInt();
            int p = 3;
            int spec = 3;

            boolean f = true;

            for(int i = 0;i<n;i++) {
                int x = in.nextInt();
                if(spec == x) {
                    f = false;
                }
                spec = 6 - x - spec;
            }

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

        }

    }

    static class ScanReader {
        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 ScanReader(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);
        }
    }
}

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

public class chess4three {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		boolean possible = true;
		boolean alex = true;
		boolean bob = true;
		boolean carl = false;
		for (int i = 0; i < n; i++) {
			int winner = Integer.parseInt(reader.readLine());
			if ((winner == 1 && !alex) || (winner == 2 && !bob) || (winner == 3 && !carl)) {
				possible = false;
				break;
			}
			if (winner == 1) {
				if (bob) {
					bob = false;
					carl = true;
				} else {
					carl = false;
					bob = true;
				}

			} else if (winner == 2) {
				if (carl) {
					carl = false;
					alex = true;
				} else {
					alex = false;
					carl = true;
				}
			} else {
				if (alex) {
					alex = false;
					bob = true;
				} else {
					bob = false;
					alex = true;
				}
			}
		}
		System.out.println(possible ? "YES" : "NO");
	}
}

//package cf_educational_33;

//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here
        ProblemA solver;
//        try{
//                File f = new File("src/cf_educational_33/input.txt");
//                solver = new ProblemA( new FileInputStream(f),System.out);
//        }catch(FileNotFoundException ex){
                solver = new ProblemA( System.in,System.out);
//        }

        solver.solve();
    }

}
class ProblemA{
    private final Scanner scanner;
    private final PrintStream output;
    public ProblemA(InputStream input,PrintStream output){
        this.scanner = new Scanner(input);
        this.output=output;
    }
    public void solve(){
        int numGames = scanner.nextInt();
        int p1 = 1;
        int p2 = 2;
        int ex = 3;
        boolean possible = true;
        while(numGames-- > 0){
            int winner = scanner.nextInt();
            if(winner == p1 || winner == p2){
                p1 = winner;
                p2 = ex;
                ex = 1+2+3-p1-p2;
            }else{
                possible = false;
            }
        }
        if(possible){
            output.println("YES");
        }else{
            output.println("NO");
        }
    }
}

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    MyScanner2 in=new MyScanner2(System.in);
	    int w=0,l=0,c=3,d=1;
	    int n=in.nextInt();
	    w=in.nextInt();
	    --n;
	    if(w==3)
	    {
	        d=0;
	    }
	    else
	    {
	        if(w==1)
	        {
	            c=2;
	            l=3;
	        }
	        else if(w==2)
	        {
	            l=3;
	            c=1;
	        }
	    }
	    while(n>0)
	    {
	        n--;
	        int ww=in.nextInt();
	        if(d==0)
	        {
	            continue;
	        }

	        if(ww==c)
	        {
	            d=0;
	            continue;
	        }

	        if(ww==l)
	        {
	            int tmp=c;
	            c=w;
	            w=tmp;

	            tmp=w;
	            w=l;
	            l=tmp;

	        }
	        else
	        {
	            int tmp=c;
	            c=l;
	            l=tmp;
	        }
	    }

		if(d==0)
		{
		    System.out.println("NO");
		}
		else
		{
		    System.out.println("YES");
		}

	}
}

class MyScanner2
{
   final private int BUFFER_SIZE = 1 << 16;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public MyScanner2(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }

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

   //reads in the next string
   public String next() throws Exception
   {
      StringBuilder ret =  new StringBuilder();
      byte c = read();
      while (c <= ' ') c = read();
      do
      {
         ret = ret.append((char)c);
         c = read();
      } while (c > ' ');
      return ret.toString();
   }

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

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

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

/*
 * 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 pkg893a;

import java.util.Scanner;

/**
 *
 * @author pranto
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
       int ck=3;
       boolean flag=true;
       for(int i=0;i<n;i++){
       int a=in.nextInt();
       if(a==ck){
           System.out.println("NO");
           flag=false;
       break;
       }

       ck=6-ck-a;

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

    }

}

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

public class A
{

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

        //START//
        int n = in.nextInt();
        int wi=1,ch=2,ob=3;
        boolean consistent = true;
        for (i = 0; i < n; i++)
        {
            int res = in.nextInt();
            if (res == ob)
            {
                consistent = false;

            }
            else if (res == wi)
            {
                int temp = ob;
                ob = ch;
                ch=temp;
            }
            else
            {
                int temp = wi;
                wi = ch;
                ch = temp;

                int temp2 = ob;
                ob = ch;
                ch = temp2;
            }
        }
        if (consistent)
            out.println("YES");
        else
            out.println("NO");

        //END

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

    public static void main(String[] args)
    {
        new A().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.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] score = new int[]{1,1,0};
        int index =0;
        boolean flag = true;
        for(int i=0;i<n;i++){
            int w=scan.nextInt();
            if(w==3&&i==0){flag=false;break;}
            if(i==0&&n==1){flag=true;break;}
            if(score[w-1]==-1){flag=false;break;}
            for(int k=0;k<3;k++){
                if((w-1!=k&&score[k]==0)||(w-1!=k&&score[k]==1)){score[w-1]=1;score[k]=-1;index=k;break;}
            }
            for(int k=0;k<3;k++){
                if(index!=k&&score[k]==-1){score[k]=0;}
            }

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

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

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		int[] wins = new int[n];
		for(int i = 0; i < n; i++) {
			wins[i] = Integer.parseInt(in.nextLine());
		}
		boolean flag = true;
		int[] game = {1,2};
		for(int i = 0; i < n; i++) {
			if(wins[i] == 1) {
				if(game[1]==1) {
					if(game[0]==2)
						game[0] = 3;
					else
						game[0] = 2;
				}
				else if(game[0] ==1) {
					if(game[1]==2)
						game[1] = 3;
					else
						game[1] = 2;
				}
				else {
					flag = false;
					break;
				}
			}
			else if(wins[i] == 2) {
				if(game[1]==2) {
					if(game[0]==1)
						game[0] = 3;
					else
						game[0] = 1;
				}
				else if(game[0] ==2) {
					if(game[1]==1)
						game[1] = 3;
					else
						game[1] = 1;
				}
				else {
					flag = false;
					break;
				}
			}
			else if(wins[i] == 3) {
				if(game[1]==3) {
					if(game[0]==1)
						game[0] = 2;
					else
						game[0] = 1;
				}
				else if(game[0] == 3) {
					if(game[1]==1)
						game[1] = 2;
					else if(game[1]==2)
						game[1] = 1;
				}
				else {
					flag = false;
					break;
				}

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

	}

}

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

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        int n = in.readInt();
       int s =3;
       boolean check = true;
       for (int i =0;i<n;i++)
       {
           int u = in.readInt();
           if (u==s)
           {
               check = false;

           }
           else
           {
               if (u!=2&&s!=2)
                   s=2;
               else  if (u!=1&&s!=1)
                   s=1;
               else
                   s=3;
           }
       }
        System.out.println((check)?"YES":"NO");

    }

  static int BFS(Graph g,int n,int start)
   {
       boolean[]visited = new boolean[n];
       Queue<Integer> q = new LinkedList<>();
       visited[start] = true;
       q.add(start);
       int counter =0;
       while(!q.isEmpty())
       {
           int index = q.poll();
counter++;
           for (int i=0;i<g.adjList[index].size();i++ )
           {

               if (!visited[g.adjList[index].get(i)]) {
                   visited[g.adjList[index].get(i)] = true;
                   q.add(g.adjList[index].get(i));
               }
           }
       }
       return  counter;
   }

   static void addEdgeUni(Graph g ,int i,int j)
   {
       g.adjList[i].addFirst(j);
       g.adjList[j].addFirst(i);
   }
   static void addEdgeDir(Graph g ,int i,int j)
   {
       g.adjList[i].addFirst(j);
   }

    static    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()
    static   void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle polong
            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);
        }
    }
}
class Graph {

    int n;
    LinkedList<Integer>[] adjList;

    public Graph(int n) {
        this.n = n;
        adjList = new LinkedList[n];
        for (int i = 0; i < n; i++)
            adjList[i] = new LinkedList<>();
    }

}
class LazySegmentTree
{
    final int MAX = 1000;        // Max tree size
    int tree[] = new int[MAX];  // To store segment tree
    int lazy[] = new int[MAX];  // To store pending updates

    /*  si -> index of current node in segment tree
        ss and se -> Starting and ending indexes of elements for
                     which current nodes stores sum.
        us and eu -> starting and ending indexes of update query
        ue  -> ending index of update query
        diff -> which we need to add in the range us to ue */
    void updateRangeUtil(int si, int ss, int se, int us,
                         int ue, int diff)
    {
        // If lazy value is non-zero for current node of segment
        // tree, then there are some pending updates. So we need
        // to make sure that the pending updates are done before
        // making new updates. Because this value may be used by
        // parent after recursive calls (See last line of this
        // function)
        if (lazy[si] != 0)
        {
            // Make pending updates using value stored in lazy
            // nodes
            tree[si] += (se - ss + 1) * lazy[si];

            // checking if it is not leaf node because if
            // it is leaf node then we cannot go further
            if (ss != se)
            {
                // We can postpone updating children we don't
                // need their new values now.
                // Since we are not yet updating children of si,
                // we need to set lazy flags for the children
                lazy[si * 2 + 1] += lazy[si];
                lazy[si * 2 + 2] += lazy[si];
            }

            // Set the lazy value for current node as 0 as it
            // has been updated
            lazy[si] = 0;
        }

        // out of range
        if (ss > se || ss > ue || se < us)
            return;

        // Current segment is fully in range
        if (ss >= us && se <= ue)
        {
            // Add the difference to current node
            tree[si] += (se - ss + 1) * diff;

            // same logic for checking leaf node or not
            if (ss != se)
            {
                // This is where we store values in lazy nodes,
                // rather than updating the segment tree itelf
                // Since we don't need these updated values now
                // we postpone updates by storing values in lazy[]
                lazy[si * 2 + 1] += diff;
                lazy[si * 2 + 2] += diff;
            }
            return;
        }

        // If not completely in rang, but overlaps, recur for
        // children,
        int mid = (ss + se) / 2;
        updateRangeUtil(si * 2 + 1, ss, mid, us, ue, diff);
        updateRangeUtil(si * 2 + 2, mid + 1, se, us, ue, diff);

        // And use the result of children calls to update this
        // node
        tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2];
    }

    // Function to update a range of values in segment
    // tree
    /*  us and eu -> starting and ending indexes of update query
        ue  -> ending index of update query
        diff -> which we need to add in the range us to ue */
    void updateRange(int n, int us, int ue, int diff)  {
        updateRangeUtil(0, 0, n - 1, us, ue, diff);
    }

    /*  A recursive function to get the sum of values in given
        range of the array. The following are parameters for
        this function.
        si --> Index of current node in the segment tree.
               Initially 0 is passed as root is always at'
               index 0
        ss & se  --> Starting and ending indexes of the
                     segment represented by current node,
                     i.e., tree[si]
        qs & qe  --> Starting and ending indexes of query
                     range */
    int getSumUtil(int ss, int se, int qs, int qe, int si)
    {
        // If lazy flag is set for current node of segment tree,
        // then there are some pending updates. So we need to
        // make sure that the pending updates are done before
        // processing the sub sum query
        if (lazy[si] != 0)
        {
            // Make pending updates to this node. Note that this
            // node represents sum of elements in arr[ss..se] and
            // all these elements must be increased by lazy[si]
            tree[si] += (se - ss + 1) * lazy[si];

            // checking if it is not leaf node because if
            // it is leaf node then we cannot go further
            if (ss != se)
            {
                // Since we are not yet updating children os si,
                // we need to set lazy values for the children
                lazy[si * 2 + 1] += lazy[si];
                lazy[si * 2 + 2] += lazy[si];
            }

            // unset the lazy value for current node as it has
            // been updated
            lazy[si] = 0;
        }

        // Out of range
        if (ss > se || ss > qe || se < qs)
            return 0;

        // At this point sure, pending lazy updates are done
        // for current node. So we can return value (same as
        // was for query in our previous post)

        // If this segment lies in range
        if (ss >= qs && se <= qe)
            return tree[si];

        // If a part of this segment overlaps with the given
        // range
        int mid = (ss + se) / 2;
        return getSumUtil(ss, mid, qs, qe, 2 * si + 1) +
                getSumUtil(mid + 1, se, qs, qe, 2 * si + 2);
    }

    // Return sum of elements in range from index qs (query
    // start) to qe (query end).  It mainly uses getSumUtil()
    int getSum(int n, int qs, int qe)
    {
        // Check for erroneous input values
        if (qs < 0 || qe > n - 1 || qs > qe)
        {
            System.out.println("Invalid Input");
            return -1;
        }

        return getSumUtil(0, n - 1, qs, qe, 0);
    }

    /* A recursive function that constructs Segment Tree for
      array[ss..se]. si is index of current node in segment
      tree st. */
    void constructSTUtil(int arr[], int ss, int se, int si)
    {
        // out of range as ss can never be greater than se
        if (ss > se)
            return;

        /* If there is one element in array, store it in
         current node of segment tree and return */
        if (ss == se)
        {
            tree[si] = arr[ss];
            return;
        }

        /* If there are more than one elements, then recur
           for left and right subtrees and store the sum
           of values in this node */
        int mid = (ss + se) / 2;
        constructSTUtil(arr, ss, mid, si * 2 + 1);
        constructSTUtil(arr, mid + 1, se, si * 2 + 2);

        tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2];
    }

    /* Function to construct segment tree from given array.
       This function allocates memory for segment tree and
       calls constructSTUtil() to fill the allocated memory */
    void constructST(int arr[], int n)
    {
        // Fill the allocated memory st
        constructSTUtil(arr, 0, n - 1, 0);
    }
}

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 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);
    }
}

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 printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}

import java.util.*;
public class Chess4Three {

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

		int num = in.nextInt();

		int winner = 0;
		int spectator=3;
		String result = "YES";
		for(int i = 0; i<num;i++){
			winner = in.nextInt();
			if(winner == spectator) result = "NO";
			else spectator = 6-winner-spectator;
		}
		System.out.println(result);
	}

}

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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Reader in = new Reader();
    public static void main(String[] args) throws IOException {
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();

    }

    static int INF = (int)1e9;
    static int maxn = (int)1e5+5;
    static int mod  = 998244353;
    static int n,m,q,k,t;

    void solve() throws IOException{
        n = in.nextInt();

        boolean[] vis = new boolean[4];

        boolean ans = true;
        vis[1] = true;
        vis[2] = true;
        for (int i = 0;i < n; i++) {
            int tmp = in.nextInt();
            if(!vis[tmp]) ans = false;

            for (int j = 1; j <= 3; j++) {
                if (j == tmp) continue;
                if (vis[j]) vis[j] = false;
                else vis[j] = true;
            }
        }

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

    //<>

    static class Reader {

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

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

    public Reader(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 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();
    }

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

    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;
    }

    }
}

import java.util.Scanner;
public class chess
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        int n= s.nextInt();
        int a[]= new int[n];
        int x= 1, y=2, z=3, i, t, count=0;
        for(i=0; i<n; i++)
        {
            a[i]= s.nextInt();
            if(a[i]==x)
            {
                t=y;
                y=z;
                z=t;
            }
            else if(a[i]==y)
            {
                t=x;
                x=z;
                z=t;
            }
            else if(a[i]==z)
            {
                System.out.println("NO");
                break;
            }
            count++;
        }
        if(count==n)
        System.out.println("YES");
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author school_olimp
 */
public class JVM {

    /**
     * @param args the command line arguments
     */
    static String[] dmitry_ivanovich;
    static String s;
    /**
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = 3;
        int p1 = 1;
        int p2 = 2;

        for(int i = 0; i < n; i++){
            int m = sc.nextInt();
            if(w == m) {
                System.out.println("NO");
                return;
            }
            else if (m == p1){
                int k = p2;
                p2 = w;
                w = k;
            }
            else{
                int k = p1;
                p1 = w;
                w = k;
            }
        }
        System.out.println("YES");
    }

}

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

    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
     int n=in.nextInt();
     int p1=1,p2=2,spec=3,temp,i;
     int[] a=new int[n];
     for(i=0;i<n;i++)
     {
         a[i]=in.nextInt();

     if(a[i]==p1)
     { temp=p2;
        p2=spec;
        spec=temp;
     }

     else if(a[i]==p2)
     {  temp=p1;
        p1=spec;
        spec=temp;
     }
     else {break;}
     }

       if(i==n)
      System.out.println("YES");
        else
           System.out.println("NO");

            }}

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

public class solution {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int a = 1;
        int b = 2;
        boolean arr[] = new boolean[4];
        arr[1] = true;
        arr[2] = true;
        boolean flag = true;
        for(int i=0;i<n;i++){
            int c = Integer.parseInt(br.readLine());
            if(c!=a && c!=b){
                flag = false;
            }
            else if (c == a){
                int d = b;
                for(int j=1;j<4;j++){
                    if(arr[j] == false){
                        b = j;
                        arr[j] = true;
                        break;
                    }
                }
                arr[d] = false;
            }
            else{
                int d = a;
                for(int j=1;j<4;j++){
                    if(arr[j] == false){
                        a = j;
                        arr[j] = true;
                        break;
                    }
                }
                arr[d] = false;
            }
        }
        if(flag){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

import java.util.*;
import javax.swing.JOptionPane;

public class main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        LinkedList<Character> list = new LinkedList<Character>();
        list.add('A');
        list.add('B');
        list.add('C');
        int var, count = 0;
        int n = input.nextInt();
        for (int i = 0; i < n; i++) {
            var = input.nextInt();
            switch (var) {
                case 1: // Este es el caso en el que el Jugador A gana
                    if (list.get(0) == 'A' || list.get(1) == 'A') {
                        list.remove(list.indexOf('A'));
                        list.add(0, 'A');
                        char X = list.get(2);
                        list.remove(list.indexOf(X));
                        list.add(1, X);
                        count++;
                    }
                    break;
                case 2: //Este es el caso en el que el jugador B gana
                    if (list.get(0) == 'B' || list.get(1) == 'B') {
                        list.remove(list.indexOf('B'));
                        list.add(0, 'B');
                        char X = list.get(2);
                        list.remove(list.indexOf(X));
                        list.add(1, X);
                        count++;
                    }
                    break;
                case 3: //Este es el caso en el que el jugador C gana
                    if (list.get(0) == 'C' || list.get(1) == 'C') {
                        list.remove(list.indexOf('C'));
                        list.add(0, 'C');
                        char X = list.get(2);
                        list.remove(list.indexOf(X));
                        list.add(1, X);
                        count++;
                    }
                    break;
                default:

            }

        }
        if (count == n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

		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.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;

					public class Solution1 implements Runnable
					{
						static final int MAX = 1000000007;
						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);
							}
						}

						public static void main(String args[]) throws Exception
						{
							new Thread(null, new Solution1(),"Solution1",1<<26).start();
						}
						long power(long x, long y)
						{
						    long res = 1;      // Initialize result

						    x = x % MAX;  // Update x if it is more than or
						                // equal to p

						    while (y > 0)
						    {
						        // If y is odd, multiply x with result
						        if (y % 2 == 1)
						            res = (res*x) % MAX;

						        // y must be even now
						        y = y>>1; // y = y/2
						        x = (x*x) % MAX;
						    }
						    return res;
						}
						public void run()
						{
							InputReader sc= new InputReader(System.in);
							PrintWriter w= new PrintWriter(System.out);
							int n = sc.nextInt();
							int[] arr = new int[n];
							for(int i =  0;i < n;i++){
								arr[i]  =sc.nextInt();
							}
							int one = 1;
							int two = 2;
							int three = 3;
							for(int i = 0;i < n;i++){
								if(arr[i] != one && arr[i] != two){
									w.print("NO");
									w.close();
									System.exit(0);
								}else{
									if(arr[i] == one){
										int tmep = two;
										two = three;
										three=   tmep;
									}else{
										int tmep = one;
										one = three;
										three = tmep;
									}
								}
							}
							w.println("YES");
							w.close();
						}
						public static int gcd(int a, int b)
					    {
					        if (a == 0)
					            return b;

					        return gcd(b%a, a);
					    }
						static class Pair implements Comparable<Pair>{
							int a;
							int b;
							Pair(int a,int b)	{
								this.a = a;
								this.b = b;
							}
							public boolean equals(Object o)
							{
								Pair p = (Pair)o;
								return p.a==a && p.b==b;
							}
							public int compareTo(Pair p){
								return Long.compare(this.a,p.a);
							}
							public int hashCode()
							{
								return new Long(a).hashCode()*31 + new Long(a).hashCode();
							}
						}
					}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
			int games = scan.nextInt();

			int[] wins = new int[games];
			for(int count = 0 ;count < games ; count ++)
				wins[count]= scan.nextInt();

			int p1 = 1, p2 = 2, s=3;
			for(int count = 0 ; count < games ;count++){

				if(wins[count] == s){
					System.out.println("NO");
					break;
				}
				else{
					int temp;
					int temp2;
					if(wins[count]==p1){
						 temp = p2;
						 p2 = s;
					}
					else{
						temp = p1;
						p1 = s;
					}
					s = temp;
				}
				if(count==games-1)
					System.out.println("YES");
			}

	}

}

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
 *
 * @author ljy
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int player1 = 1, player2 = 2, other = 3;
            for (int i = 0; i < n; i++) {
                int win = in.nextInt();
                if (win == other) {
                    out.println("NO");
                    return;
                } else if (win == player1) {
                    player1 = win;
                    player2 = swap(other, other = player2);
                } else {
                    player2 = win;
                    player1 = swap(other, other = player1);
                }
            }
            out.print("YES");
        }

        private static int swap(int a, int b) {
            return a;
        }

    }

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

        public 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());
        }

    }
}

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);
        A33 solver = new A33();
        solver.solve(1, in, out);
        out.close();
    }

    static class A33 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.scanInt();
            }

            if (arr[0] == 1 || arr[0] == 2) {

                int w = arr[0];
                int spe;
                if (w == 1)
                    spe = 2;
                else
                    spe = 1;

                int nextplayer = 3;

                for (int i = 1; i < n; i++) {
                    if (arr[i] == w || arr[i] == nextplayer) {

                    } else {
                        out.println("NO");
                        return;
                    }

//                if(arr[i] == spe )
//                {
//                    out.println("NO");
//                    return;
//                }

                    int t = spe;

                    if (arr[i] == w) {
                        spe = nextplayer;
                    } else {
                        spe = w;
                    }

                    nextplayer = t;

                    w = arr[i];
                }

                out.println("YES");
            } else {
                out.println("NO");
                return;
            }

        }

    }

    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.*;
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[] aa=new int[t];
        for (int i = 0; i <t ; i++) {
            aa[i]=ii();
        }
        int flag=0;
        int a=1,b=2;
        for (int i = 0; i <t ; i++) {
            if(aa[i]==a)
                b=6-(a+b);
            else if(aa[i]==b)
                a=6-(a+b);
            else {
                flag = 1;
                break;
            }

        }

        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;
    }

}

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

public class Main {

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

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(System.in), 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 static void main(String[] args) {
		// InputStream inputStream = System.in; // Useful when taking input other than
		// console eg file handling // check ctor of inputReader
		InputReader scn = new InputReader();

		int n = scn.nextInt();

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

		if (arr[0] == 3) {
			System.out.println("NO");
			return;
		}

		int l;
		if (arr[0] == 1) {
			l = 2;
		} else {
			l = 1;
		}
		for (int i = 1; i < n; i++) {
			if (arr[i] == l) {
				System.out.println("NO");
				return;
			} else {
				for(int j = 1; j <= 3; j++) {
					if(arr[i] != j && l != j) {
						l = j;
						break;
					}
				}
			}
		}
		System.out.println("YES");
	}
}

/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

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

public class Main{

        static int MOD = (int)1e9+7;

        // for dfs
        static int n;
        static int ansi;
        static int[] w;
        static int[] ww;
        static boolean[] isvisited;
        //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int spec = 0;
        for (int i = 0; i < n; i++) {
            int winner = sc.nextInt() % 3;
            // winner

            if (winner == spec) {
                System.out.println("NO");
                return;
                // tozen!
            }else{
                // loser -> spectator
                int tmp = (winner+1) % 3;
                if (tmp == spec) {
                    spec = (tmp+1)%3;
                }else{
                    spec = tmp;
                }
            }
        }

        System.out.println("YES");

        sc.close();
    }

    /*
    For Numeric Analysis
    */
    public static int ManhattanDist(int x, int y, int xx, int yy) {
        return(Math.abs(xx-x) + Math.abs(yy-y));
    }

    public static double FuncOfx(double x, int funcnum) {
        switch (funcnum) {
            case 1:
                return x*x;

            case 2:
                return Math.exp(-1*x)-x*x;

            default:
                throw new IllegalArgumentException("Such Func doesn't Exist.");
        }

    }

    public static void Nibutan(double target, int funcnum) {
        int callcounter = 0;
        double lowbound = Integer.MIN_VALUE;
        double highbound = Integer.MAX_VALUE;
        double pivot = (lowbound + highbound)/2;
        double tmp;
        double tmp4swap;
        if (funcnum == 1) {
            lowbound = 0;
            pivot = (lowbound+highbound)/2;
        }
        while (true) {
            callcounter++;
            if (FuncOfx(highbound, funcnum) < FuncOfx(lowbound, funcnum)) {
                tmp4swap = highbound;
                highbound = lowbound;
                lowbound = tmp4swap;
            }

            if (FuncOfx(pivot,funcnum) > target) {
                System.out.println(String.format("%2d", callcounter) + ": "
                            + String.format("%.6f", pivot) + " f(" + String.format("%.6f", pivot) +") is "
                            + String.format("%.6f",FuncOfx(pivot,funcnum))  + ", so too high :(");
                tmp = (lowbound + pivot)/2;
                if ( Math.abs(tmp-pivot) < 0.00005 ) {
                    System.out.println("Found!" +String.format("%.3f", tmp)+" is the answer.");
                    return;
                }
                highbound = pivot;
                pivot = tmp;
            }else if(FuncOfx(pivot,funcnum) < target){
                System.out.println(String.format("%2d", callcounter) + ": "
                            + String.format("%.6f", pivot) + " f(" + String.format("%.6f", pivot) +") is "
                            + String.format("%.6f",FuncOfx(pivot,funcnum))  + ", so too high :(");
                tmp = (highbound + pivot)/2;
                if ( Math.abs(tmp-pivot) < 0.00005 ) {
                    System.out.println("Found!" +String.format("%.3f", tmp)+" is the answer.");
                    return;
                }
                lowbound = pivot;
                pivot = tmp;
            }
        }

    }

    /*
    Numeric Analysis End
    */

    private static long[][] CombinationLong_nCk(long n, long k) {
        n++; k++;
        long[][] ans = new long[(int)n][(int)k];
        for (int i = 0; i < n; i++) {
            ans[i][0] = 1;
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = ans[i][j] + ans[i][j+1];
                }
            }
        }
        return ans;
    }

        public static int gcd_int(int a, int b) {

            if (a < b) {
                int tmpp = a;
                a = b;
                b = tmpp;
            }
            if (b == 0) {
                return a;
            }else{
                return gcd_int(b, a%b);
            }
        }

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

            if (a < b) {
                long tmpp = a;
                a = b;
                b = tmpp;
            }
            if (b == 0) {
                return a;
            }else{
                return gcd_long(b, a%b);
            }
        }

        public static int lcm_int(int a, int b) {
            int gcd = gcd_int(a,b);
            return a/gcd*b;
        }

        public static long lcm_long(long a, long b) {
            long gcd = gcd_long(a,b);
            return a/gcd*b;
        }

        public static void dfs(int placenow) {
            // if went all -> success!
            // if not went all -> fail...

            /*
            dfs
            Go All Place that there is way to and not having been yet.

             if island 1 is start point, dfs(1);
            if there is way to island 2 and island 3,
            - island 2 changes non-visited -> visited, and dfs(2).
            - island 3 changes non-visited -> visited, and dfs(3).

            */

            isvisited[placenow] = true;
            boolean success = true;
            for (int i = 0; i < n; i++) {
                if (isvisited[i] == false) { // not go all place
                    success = false;
                    break;
                }
            }
            if (success) {
                ansi++;
                isvisited[placenow] = false;
                return;
            }

            for (int i = 0; i < n; i++) {
                if (w[i] == placenow && isvisited[ww[i]] == false ) {
                    dfs(ww[i]);
                }else if(ww[i] == placenow && isvisited[w[i]] == false){
                    dfs(w[i]);
                }else{
                    continue;
                }
            }
            isvisited[placenow] = false;
            return;
        }

}

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

public class Main {
    static Reader in;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        in = new Reader();
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        new Solution();
        out.close();
    }

    static class Solution {
        Solution() {
            int n = in.nextInt();
            int[] games = new int[n];
            for(int i=0; i<n; i++) {
                games[i] = in.nextInt();
            }

            int alex = 0;
            int bob = 0;
            int carl = 0;

            boolean flag = false;
            boolean avoid = false;

            if(games[0]==1)
                ++bob;
            else if(games[0]==2)
                ++alex;
            else if(games[0]==3) {
                flag = true;
                avoid = true;
            }

            if(!avoid) {
                for(int i=1; i<n; i++) {
                    if(bob>1 || carl>1 || alex>1) {
                        flag = true;
                        break;
                    }
                    if(bob!=0 && carl==0 && alex==0) {
                        if(bob>1 || carl>1 || alex>1) {
                            flag = true;
                            break;
                        } else if(bob==1 && games[i]==2) {
                            flag = true;
                            break;
                        } else {
                            if(games[i]==3) {
                                --bob;
                                ++alex;
                            } else if(games[i]==1) {
                                --bob;
                                ++carl;
                            }
                        }
                    } else if(alex!=0 && bob==0 && carl==0) {
                        if(bob>1 || carl>1 || alex>1) {
                            flag = true;
                            break;
                        } else if(alex==1 && games[i]==1) {
                            flag = true;
                            break;
                        } else {
                            if(games[i]==2) {
                                --alex;
                                ++carl;
                            } else if(games[i]==3) {
                                --alex;
                                ++bob;
                            }
                        }
                    } else if(carl!=0 && bob==0 && alex==0) {
                        if(bob>1 || carl>1 || alex>1) {
                            flag = true;
                            break;
                        } else if(carl==1 && games[i]==3) {
                            flag = true;
                            break;
                        } else {
                            if(games[i]==1) {
                                --carl;
                                ++bob;
                            } else if(games[i]==2) {
                                --carl;
                                ++alex;
                            }
                        }
                    }
                }
            }
            if(flag)
                out.println("NO");
            else
                out.println("YES");
        }
    }

    static class Reader {
        public BufferedReader br;
        public StringTokenizer st;
        public Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));

        }
        public String next() {
            while(st==null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public char nextChar() {
            return next().charAt(0);
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}

import java.util.*;

public class edu33A {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int spec = 3 - scan.nextInt();
		if (spec == 0) {
			System.out.println("NO");
			return;
		}
		for (int i = 0; i < n - 1; i++) {
			int a = scan.nextInt();
			if (a == spec) {
				System.out.println("NO");
				return;
			}
			spec = sw(spec,a);
		}
		System.out.println("YES");
	}

	public static int sw(int spec, int win) {
		if (spec==1) {
			return (win==2) ? 3 : 2;
		} else if (spec ==2) {
			return (win==1) ? 3 : 1;
		} else return (win==1) ? 2 : 1;
	}

}

import java.io.*;
import java.util.*;
public class Main{
	static int[] game(int[]players,int win) {
		HashSet<Integer>all=new HashSet<>();
		all.add(1);
		all.add(2);
		all.add(3);
		all.remove(players[0]);
		all.remove(players[1]);
		int nxt=-1;
		for(int i:all) {
			nxt=i;
		}
		return new int[] {nxt,win};
	}
	static void main() throws Exception{
		int n=sc.nextInt();
		boolean ok=true;
		int[]play=new int[] {1,2};
		for(int i=0;i<n;i++) {
			play=game(play, sc.nextInt());
			if(play[0]==play[1]) {
				pw.println("NO");
				return;
			}
		}
		pw.println("YES");
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

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

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

     // public static void solve(){

     //    FastScanner sc = new FastScanner();
     //    sb = new StringBuilder();
     //    int n = sc.nextInt();
     //    int m = sc.nextInt();
     //    map = new HashMap<>();

     //    for(int i = 0 ; i < n ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        map.put(b,a);
     //    }
     //    for(int i = 0 ; i < m ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        sb.append(a+" "+b+" #"+map.get(b.substring(0,b.length()-1))+"\n");
     //    }

     //    System.out.println(sb);

     // }

     public static boolean solve(){

        int player1 = 1;
        int player2 = 2;
        int not = 3;
        for(int i = 0 ; i < n ; i++){
            if(arr[i] == not)
                return false;
            if(arr[i] == player1){
                not = player2;
                if(player2 != 1 && arr[i] != 1)
                    player2 = 1;
                else if(player2 != 2 && arr[i] != 2)
                    player2 = 2;
                else player2 = 3;
            }
            else{
                not = player1;
                if(player1 != 1 && arr[i] != 1)
                    player1 = 1;
                else if(player1 != 2 && arr[i] != 2)
                    player1 = 2;
                else player1 = 3;
            }
        }

        return true;
     }

     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){

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

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

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

                // m = sc.nextInt();

                // k = sc.nextLong();
                // 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();
                }

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

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

                // mat = new Character[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());
                }
        }

}

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

public class A1008 {
    public static void main(String [] args) {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        int n = ir.nextInt(), a = 1, b = 2, next = 3, winner;
        String result = "YES";

        for (int i = 0; i < n; i++) {
            winner = ir.nextInt();
            if (winner == a) b = next;
            else if (winner == b) a = next;
            else {
                result = "NO";
                break;
            }
            next = 6 - a - b;
        }

        pw.print(result);

    }

    boolean isPolyndrom(String str) {
        String newStr = "";
        for (int i = str.length() - 1; i >= 0; i--) newStr = newStr + str.charAt(i);
        return newStr.equals(str);
    }

    private static void Qsort(int[] array, int low, int high) {

        int i = low;
        int j = high;
        int x = array[low + (high - low) / 2];

        do {
            while (array[i] < x) ++i;
            while (array[j] > x) --j;
            if (i <= j) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);

        if (low < j) Qsort(array, low, j);
        if (i < high) Qsort(array, i, high);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

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

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}

import java.util.Scanner;

public class ArrayList {
    public static void main(String[] args) {

            Scanner sc=new Scanner(System.in);
            int n=sc.nextInt();
            int w=3;
            for (int i=0;i<n;i++){
                int a=sc.nextInt();
                if (w==a){
                    System.out.println("No");
                    return;
                }
                w=6-a-w;

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

    }

    }

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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int player1 = 1, player2 = 2, other = 3;
            for (int i = 0; i < n; i++) {
                int win = in.nextInt();
                if (win == other) {
                    out.println("NO");
                    return;
                } else if (win == player1) {
                    player1 = win;
                    player2 = swap(other, other = player2);
                } else {
                    player2 = win;
                    player1 = swap(other, other = player1);
                }
            }
            out.print("YES");
        }

        private static int swap(int a, int b) {
            return a;
        }

    }

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

        public 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());
        }

    }
}

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
 *
 * @author Rustam Musin (PloadyFree@gmail.com)
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            boolean[] active = {false, true, true, false};
            int n = in.readInt();
            for (int i = 0; i < n; i++) {
                int win = in.readInt();
                if (!active[win]) {
                    out.print("NO");
                    return;
                }
                for (int j = 0; j < active.length; j++) {
                    if (active[j]) {
                        if (win != j) {
                            active[j] = false;
                        }
                    } else {
                        active[j] = true;
                    }
                }
            }
            out.print("YES");
        }

    }

    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 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 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 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 close() {
            writer.close();
        }

    }
}

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

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);
      TaskA solver = new TaskA();
      solver.solve(1, in, out);
      out.close();
   }

   static class TaskA{
      public void solve(int testNumber, Scanner sc, PrintWriter out) {
         boolean state[] = {true, true, false};
         int n = sc.nextInt();
         boolean ok = true;
         while (n-- > 0) {
            int cur = sc.nextInt() - 1;
            ok &= state[cur];
            for (int i = 0; i < 3; i++){
               if (state[i] && i != cur)
                  state[i] = false;
               else if (!state[i])
                  state[i] = true;
            }
         }
         out.println(ok ? "YES" : "NO");
      }
   }

   static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Enmanuel Reyes
 * Date: 11/23/17
 * Time: 11:08 AM
 * <p>
 * http://codeforces.com/contest/893/problem/A
 */
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int ns[] = new int[n];
            for (int i = 0; i < n; i++) {
                ns[i] = sc.nextInt();
            }

            Player cannotWin = Player.CARL;
            Player[] players = new Player[4];
            players[1] = Player.ALEX;
            players[2] = Player.BOB;
            players[3] = Player.CARL;

            boolean valid = true;
            for (int i = 0; i < n; i++) {
                final int n1 = ns[i];
                Player won = players[n1];
                if (won == cannotWin) {
                    valid = false;
                    break;
                }
                if (won == Player.ALEX && cannotWin == Player.CARL) {
                    cannotWin = Player.BOB;
                } else if (won == Player.ALEX && cannotWin == Player.BOB) {
                    cannotWin = Player.CARL;
                }else if (won == Player.CARL && cannotWin == Player.BOB) {
                    cannotWin = Player.ALEX;
                }else if (won == Player.BOB && cannotWin == Player.ALEX) {
                    cannotWin = Player.CARL;
                }else if (won == Player.BOB && cannotWin == Player.CARL) {
                    cannotWin = Player.ALEX;
                }else if (won == Player.CARL && cannotWin == Player.ALEX) {
                    cannotWin = Player.BOB;
                }
            }
            if (valid) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

        }
    }

}
enum Player{
    Null, ALEX, BOB, CARL
}

import java.util.Scanner;

public class a {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int loser = 3;
		for(int i = 0; i < n; i++) {
			int t = in.nextInt();
			if(t == loser) {
				System.out.println("NO");
				return;
			}
			for(int j = 1; j < 4; j++) {
				if(j != t && j != loser) {
					loser = j;
					break;
				}
			}
		}
		System.out.println("YES");
	}
}

import java.util.Scanner;

public class ChessForThree {

	public static void main(String[] args) {
		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 spictator = 3;
		int jo1 = 1;
		int jo2 = 2;
		int count = 0;
		int aux = 0 ;

		for(int i=0;i<n;i++){
			if(a[i] == jo1){
				aux = jo2;
				jo2 = spictator;
				spictator = aux;
			}else if(a[i] == jo2){
				aux = jo1;
				jo1 = spictator;
				spictator = aux;
			}
			else{
				System.out.println("NO");
				System.exit(0);
			}
		}

		System.out.println("YES");

	}

}

import java.util.Scanner;

public class Solution{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int numGames = scanner.nextInt();
    scanner.nextLine();
    int player1 = 1;
    int player2 = 2;
    int spectator = 3;
    int[] winner = new int[numGames];
    int helper = -1;
    boolean error = false;
    for(int i = 0; i < numGames; i++){
    	winner[i] = scanner.nextInt();
    	scanner.nextLine();
    }

    for(int i = 0; i < numGames; i++){
        if(spectator == winner[i]){
            error = true;
            break;
        }

        if(winner[i] == player1){
            helper = player2;
            player2 = spectator;
            spectator = helper;
        }
        else if(winner[i] == player2){
            helper = player1;
            player1 = spectator;
            spectator = helper;
        }
        else{
          error=true;
          break;
        }
      }
      if(!error)
    	 System.out.println("YES");
      else
        System.out.println("NO");

  }
}

import java.util.Scanner;
//''''
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int Winner1 = 1;
        int Winner2 = 2;
        boolean flag = true;

        for(int i=0;i<n;i++){
            int a = in.nextInt();
            if(Winner1!=a && Winner2!=a){
                flag = false;
                break;
            }
            else{
                Winner2 = 6 - Winner1 - Winner2;
                Winner1 = a;
            }
        }
        if(flag){
            System.out.print("YES");
        }
        else{
            System.out.print("NO");
        }
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

public class Main {

	private static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {

		int n = in.nextInt();

		int [] a = new int[n];

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

		int [] b = new int[n];

		b[0]=3;

		boolean flag = false;

		for (int i = 1; i < b.length; i++) {
			b[i]=6-a[i-1]-b[i-1];

		}

		for (int i = 0; i < b.length; i++) {
			if(a[i]==b[i])  {
				flag = true;
				System.out.println("NO");
				break;
			}
		}
		if(!flag) System.out.println("YES");

	} static void fillAnArray(int [] a) {
		for (int i = 0; i < a.length; i++) {
			a[i]=in.nextInt();
		}
	}
	static int sumOfArray(int [] a) {
		int sum = 0;
		for (int i = 0; i < a.length; i++)
			if(a[i]>0)sum+=a[i];
		return sum;
	}
	static int numberOfElementsAboveZero(int [] a) {
		int num = 0;
		for (int i = 0; i < a.length; i++) {
			if(a[i]>0) num++;
		}
		return num;
	}
	static int min(int [] a) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < a.length; i++) {
			if(a[i]>0 && a[i]<min) {
				min=a[i];
			}
		}
		return min;
	}
	static void dis(int [] a ,int min) {
		for (int i = 0; i < a.length; i++) {
			a[i]-=min;
		}
	}
	static boolean isPrime(int n) {

		if(n < 2) return false;

		for (int i = 2; i <= (int)Math.sqrt(n); i++)
			if(n%i==0) return false;
			return true;

	}

}

import java.util.*;

public class ER33A {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int x=scan.nextInt();
		int lost=x==1?2:1;
		if(x==3) {
			System.out.println("NO");
			return;
		}
		for(int i=0;i<n-1;i++) {
			int temp=scan.nextInt();
			if(temp==lost) {
				System.out.println("NO");
				return;
			}
			if((temp==1&&lost==2)||(temp==2&&lost==1)) lost=3;
			else if ((temp==2&&lost==3)||(temp==3&&lost==2)) lost=1;
			else lost=2;
		}
		System.out.println("YES");
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class test_20171124_1 {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine());
		int arr[] = {1, 2};
		int lost = 0;

		int win = Integer.parseInt(br.readLine());
		boolean check = true;

		if(win == 1) {
			arr[0] = 1;
			arr[1] = 3;
			lost = 2;
		} else if(win == 2){
			arr[0] = 3;
			arr[1] = 2;
			lost = 1;
		} else {
			bw.write("NO");
			bw.close();
			return;
		}

		for(int i = 1; i < n; i++) {
			win = Integer.parseInt(br.readLine());

			if(arr[0] == win) {
				int temp = lost;
				lost = arr[1];
				arr[1] = temp;
			} else if(arr[1] == win){
				int temp = lost;
				lost = arr[0];
				arr[0] = temp;
			} else {
				check = false;
				break;
			}
		}

		if(check) bw.write("YES");
		else bw.write("NO");

		bw.close();
	}
}

import java.util.*;

public class A893 {

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

		int n=sc.nextInt(), winner=-1, loser=-1, player=-1, w=-1;
		boolean flag=true;
		for(int i=0; i<n; i++)
		{
			if(i==0)
			{
				winner=sc.nextInt();
				if(winner!=1 && winner!=2)
				{
					flag=false;
					break;
				}
				else if(winner==1)
				{
					loser=2;
					w=1;
				}
				else
				{
					loser=1;
					w=2;
				}
				player=3;
			}
			else
			{
				winner=sc.nextInt();
				if(winner==loser)
				{
					flag=false;
					break;
				}
				else
				{
					if(winner==player)
					{
						int tmp=loser;
						loser=w;
						w=player;
						player=tmp;
					}
					else if(winner==w)
					{
						int tmp=loser;
						loser=player;
						player=tmp;
					}
				}
			}

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

	}
}

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Stack;

public class Tester
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n=ni();
		int s=3;

		for(int i=0;i<n;i++) {
			int w=ni();
			if(s==w) {
				out.println("NO");
				return;
			}
			s=6-w-s;
		}
		out.println("YES");
	}

		void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{ new Tester().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try
			{ lenbuf = is.read(inbuf); }
			catch (IOException e)
			{ throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c)
	{ return !(c >= 33 && c <= 126); }
	private int skip()
	{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd()
	{ return Double.parseDouble(ns()); }
	private char nc()
	{ return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

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

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}

		while(true)
		{
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

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

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

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int rem = 3;
        int playerSum = 3;
        boolean flag = true;
        for(int i = 0;i<t;i++){
            int winner = sc.nextInt();
            if(winner == rem){
                System.out.println("NO");
                flag = false;
                break;
            }
            rem = playerSum - winner;
            playerSum = 6-rem;
        }
        if(flag){
            System.out.println("YES");
        }
    }
}

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

public class C893A {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
	}

	static class Solver {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int t = in.nextInt();
			int[] st = new int[4];
			st[1] = st[2] = 1;
			while(t-- > 0) {
				int w = in.nextInt();
				if(st[w] == 0) {
					System.out.println("NO");
					return;
				}
				for(int i = 1 ; i <= 3 ; i++)
					if(i != w)
						st[i] ^= 1;
			}
			System.out.println("YES");
		}
	}

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), (1<<16));
            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());
        }

    }
}

import javafx.util.Pair;

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

public class __Solution {

    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    public static void main(String[] args) {
        new __Solution().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;

    void init() throws FileNotFoundException {

        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }

        tok = new StringTokenizer("");
    }

    void run() {
        try {
            long timeStart = System.currentTimeMillis();

            init();
            solve();

            out.close();

            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart));
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

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

    String delimiter = " ";

    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());
    }

    int max(int y1, int y2) {
        if (y1 > y2)
            return y1;
        else
            return y2;
    }

    long max(long h1, long h2) {
        if (h1 > h2)
            return h1;
        else
            return h2;
    }

    long min(long h1, long h2) {
        if (h1 > h2)
            return h2;
        else
            return h1;
    }

    void solve() throws IOException {
        int j1 = 1;
        int j2 = 2;
        int n = readInt();
        for (int i = 0; i < n; i++) {
            int q3 = readInt();
            if (q3 != j1 && q3 != j2) {
                out.print("NO");
                return;
            }
            if (q3 == j1) {
                j2 = 1+2+3-q3-j2;
            } else {
                j1 = 1+2+3-q3-j1;
            }
        }
        out.print("YES");
    }
}

import java.util.Scanner;

public class ChessForThree {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //number of games

        // 0 -> spectator
        // 1 -> player/loser
        // 2 -> winner

        int alex = 1;
        int bob = 1;
        int carl = 0;

        int winner = 0;
        boolean res = true;

        for (int i = 0; i < n; i++) {
            winner = sc.nextInt();
            switch (winner) {
                case 1:
                    if (alex == 0) {    //alex was spectator
                        res = false;
                    } else {
                        alex = 2;        //alex is winner
                        if (bob == 0) {  //switch players
                            bob = 1;
                            carl = 0;
                        } else if (carl == 0) {
                            bob = 0;
                            carl = 1;
                        }
                    }
                    break;
                case 2:
                    if (bob == 0) {
                        res = false;
                    } else {
                        bob = 2;
                        if (alex == 0) {
                            alex = 1;
                            carl = 0;
                        } else if (carl == 0) {
                            alex = 0;
                            carl = 1;
                        }
                    }
                    break;
                case 3:
                    if (carl == 0) {
                        res = false;
                    } else {
                        carl = 2;
                        if (alex == 0) {
                            alex = 1;
                            bob = 0;
                        } else if (bob == 0) {
                            alex = 0;
                            bob = 1;
                        }
                    }
                    break;
            }
        }

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

        sc.close();
    }
}

import java.util.Scanner;
import java.util.stream.IntStream;

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

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

        input.close();

        boolean status = true;
        int spectator = 3;

        for(int element: arr)
        {
            if(element == spectator)
                status = false;

            spectator = findLoser(element, spectator);
        }

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

    public static int findLoser(int winner, int spec)
    {
        return IntStream.rangeClosed(1, 3).filter(i -> i != winner && i != spec)
                        .findFirst().getAsInt();
    }
}

import java.util.*;
import java.io.*;
public class cdf1{
    public static void main(String args[])throws IOException{
        Scanner sc=new Scanner(System.in);
        int i,t,n,x=1,y=2,z=3,p=0;
        t=sc.nextInt();
        boolean b=true;
        for(i=1;i<=t;i++){
            n=sc.nextInt();
            if(n!=x&&n!=y){
                b=false;
                break;
            }
            if(n==x)
            p=y;
            if(n==y)
            p=x;
            x=n;
            y=z;
            z=p;
        }
        if(b)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}

import java.util.Scanner;

public class Chess {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int f = 1;
		int t = 2;
		int o = 3;
		boolean pos = true;
		for(int i = 0; i < n; i++) {
			//System.out.println(f + " vs " + t);
			int k = sc.nextInt();
			if(k == f) {
				int h = o;
				o = t;
				t = h;
			} else if(k == t) {
				int h = o;
				o = f;
				f = h;
			} else {
				pos = false;
				break;
			}
		}
		System.out.println(pos ? "YES" : "NO");
	}
}

import java.util.*;

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

		int n = kbd.nextInt();
		int count = 0;
		int p = 3;

		for(int j = 0; j < n; j++){
			int x = kbd.nextInt();
			if(x== p) {
				count++;
			} else {
				p = 6 - x - p;
			}
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

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

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);
      TaskA solver = new TaskA();
      solver.solve(1, in, out);
      out.close();
   }

   static class TaskA{
      public void solve(int testNumber, Scanner sc, PrintWriter out) {
         boolean state[] = {true, true, false};
         int n = sc.nextInt();
         boolean ok = true;
         while (n-- > 0) {
            int cur = sc.nextInt() - 1;
            ok &= state[cur];
            for (int i = 0; i < 3; i++){
               if (state[i] && i != cur)
                  state[i] = false;
               else if (!state[i])
                  state[i] = true;
            }
         }
         out.println(ok ? "YES" : "NO");
      }
   }

   static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

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

    }
}

import java.util.Scanner;
public class chess
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        int n= s.nextInt();
        int a[]= new int[n];
        int x= 1, y=2, z=3, i, t, count=0;
        for(i=0; i<n; i++)
        {
            a[i]= s.nextInt();
            if(a[i]==x)
            {
                t=y;
                y=z;
                z=t;
            }
            else if(a[i]==y)
            {
                t=x;
                x=z;
                z=t;
            }
            else if(a[i]==z)
            {
                System.out.println("NO");
                break;
            }
            count++;
        }
        if(count==n)
        System.out.println("YES");
    }
}

import java.util.Scanner;
public class Codeforces
{
    public static void main(String[] args)
    {
      Scanner scan=new Scanner(System.in);
      int n=scan.nextInt();
      int[] arr=new int[n];
      int[] brr=new int[3];
      brr[0]=1;
      brr[1]=2;
      brr[2]=3;
      for(int i=0;i<n;i++)
      {
          arr[i]=scan.nextInt();
      }

        for(int i=0;i<n;i++)
        {
           if(arr[i]==brr[0])
           {
               int temp=brr[1];
               brr[1]=brr[2];
               brr[2]=temp;
           }
           else if(arr[i]==brr[1])
           {
               int temp=brr[0];
               brr[0]=brr[2];
               brr[2]=temp;
           }
           else
           {
               System.out.print("NO");
               System.exit(0);
           }
        }
        System.out.print("YES");

    }
}

import java.util.Scanner;

public class Solution{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int numGames = scanner.nextInt();
    scanner.nextLine();
    int player1 = 1;
    int player2 = 2;
    int spectator = 3;
    int[] winner = new int[numGames];
    int helper = -1;
    boolean error = false;
    for(int i = 0; i < numGames; i++){
    	winner[i] = scanner.nextInt();
    	scanner.nextLine();
    }

    for(int i = 0; i < numGames; i++){
        if(spectator == winner[i]){
            error = true;
            break;
        }

        if(winner[i] == player1){
            helper = player2;
            player2 = spectator;
            spectator = helper;
        }
        else if(winner[i] == player2){
            helper = player1;
            player1 = spectator;
            spectator = helper;
        }
        else{
          error=true;
          break;
        }
      }
      if(!error)
    	 System.out.println("YES");
      else
        System.out.println("NO");

  }
}

import java.util.Scanner;

public class ChessForThree {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int temp=1,a=1,b=2,spec=3,temp1;
        int ans=sc.nextInt();
        //temp=ans;
        if(ans==a || ans==b){
            for(int i=0;i<n-1;i++){
                if(ans==a){
                    a=ans;
                    temp1=b;
                    b=spec;
                    spec=temp1;
                }
                else{
                    b=ans;
                    temp1=a;
                    a=spec;
                    spec=temp1;
                }
                ans=sc.nextInt();
                if(ans==a || ans==b){
                    temp+=1;
                    //System.out.println("World");
                }
                else{
                    //System.out.println("Hello");
                    System.out.println("No");
                    //System.out.println("Hi");
                    break;
                }
            }
            if(temp==n){
                System.out.println("Yes");
            }
        }
        else{
            //System.out.println("Hello1");
            System.out.println("No");
        }
    }
}

import java.util.Scanner;

public class ChessForThree {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = s.nextInt();
        int player1 = 1, player2 = 2, spectator = 3;
        boolean b = true;
        for(int i = 0; i < n; i++) {
            if(player1 != a[i] && player2 != a[i]) {
                b = false;
                break;
            }
            if(a[i] == 1) {
                if(player1 == 1) {
                    int temp = player2;
                    player2 = spectator;
                    spectator = temp;
                }
                else if(player2 == 1) {
                    int temp = player1;
                    player1 = spectator;
                    spectator = temp;
                }
            }
            else if(a[i] == 2) {
                if(player1 == 2) {
                    int temp = player2;
                    player2 = spectator;
                    spectator = temp;
                }
                else if(player2 == 2) {
                    int temp = player1;
                    player1 = spectator;
                    spectator = temp;
                }
            }
            else if(a[i] == 3) {
                if(player1 == 3) {
                    int temp = player2;
                    player2 = spectator;
                    spectator = temp;
                }
                else if(player2 == 3) {
                    int temp = player1;
                    player1 = spectator;
                    spectator = temp;
                }
            }
        }
        System.out.println(b ? "YES" : "NO");
    }
}

//package EducationalCodeforcesRound33;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		int n,a,b,s,temp,f=0,t;
		n=scanner.nextInt();
		s=3;
		a=1;
		b=2;

		for(int i=0;i<n;i++)
		{
			temp=scanner.nextInt();
			if(temp==s)
				f=1;
			else
			{
				if(temp==a)
				{
					t=s;
					s=b;
					b=t;
				}
				else
				{
					t=s;
					s=a;
					a=t;
				}
			}
		}
		if(f==1)
			System.out.println("NO");
		else
			System.out.println("YES");

	}

}

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

public class ChessForThree {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(br.readLine());
        }

        int w=1, l=2, s=3;
        for(int i=0; i<n; i++){
            if(a[i] == s){
                System.out.println("NO");
                return;
            } else {
                if(a[i]==w){
                    int temp = s;
                    s = l;
                    l = temp;
                } else {
                    int temp = s;
                    s = w;
                    w = temp;
                }
            }
        }
        System.out.println("YES");
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class test_20171124_1 {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine());
		int arr[] = {1, 2};
		int lost = 0;

		int win = Integer.parseInt(br.readLine());
		boolean check = true;

		if(win == 1) {
			arr[0] = 1;
			arr[1] = 3;
			lost = 2;
		} else if(win == 2){
			arr[0] = 3;
			arr[1] = 2;
			lost = 1;
		} else {
			bw.write("NO");
			bw.close();
			return;
		}

		for(int i = 1; i < n; i++) {
			win = Integer.parseInt(br.readLine());

			if(arr[0] == win) {
				int temp = lost;
				lost = arr[1];
				arr[1] = temp;
			} else if(arr[1] == win){
				int temp = lost;
				lost = arr[0];
				arr[0] = temp;
			} else {
				check = false;
				break;
			}
		}

		if(check) bw.write("YES");
		else bw.write("NO");

		bw.close();
	}
}

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Enmanuel Reyes
 * Date: 11/23/17
 * Time: 11:08 AM
 * <p>
 * http://codeforces.com/contest/893/problem/A
 */
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            int ns[] = new int[n];
            for (int i = 0; i < n; i++) {
                ns[i] = sc.nextInt();
            }

            Player cannotWin = Player.CARL;
            Player[] players = new Player[4];
            players[1] = Player.ALEX;
            players[2] = Player.BOB;
            players[3] = Player.CARL;

            boolean valid = true;
            for (int i = 0; i < n; i++) {
                final int n1 = ns[i];
                Player won = players[n1];
                if (won == cannotWin) {
                    valid = false;
                    break;
                }
                if (won == Player.ALEX && cannotWin == Player.CARL) {
                    cannotWin = Player.BOB;
                } else if (won == Player.ALEX && cannotWin == Player.BOB) {
                    cannotWin = Player.CARL;
                }else if (won == Player.CARL && cannotWin == Player.BOB) {
                    cannotWin = Player.ALEX;
                }else if (won == Player.BOB && cannotWin == Player.ALEX) {
                    cannotWin = Player.CARL;
                }else if (won == Player.BOB && cannotWin == Player.CARL) {
                    cannotWin = Player.ALEX;
                }else if (won == Player.CARL && cannotWin == Player.ALEX) {
                    cannotWin = Player.BOB;
                }
            }
            if (valid) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }

        }
    }

}
enum Player{
    Null, ALEX, BOB, CARL
}

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

public class solution {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int p1= 1, p2 = 2, sp = 3;
    int n = scanner.nextInt();
    for (int i = 0; i < n; i++) {
        int winner = scanner.nextInt();
        if (p1 == winner) {
            int k = p2;
            p2 = sp;
            sp = k;
        } else if (p2 == winner) {
            int k = p1;
            p1 = sp;
            sp = k;
        } else {
            System.out.printf("NO");
            return;
        }
    }
    System.out.printf("YES");
  }
}

import java.util.*;
public class me
{
   public static void main(String[] args)
   {
      Scanner br=new Scanner(System.in);
     int n=br.nextInt();
     int flag1=1;
     int flag2=1;
     int flag3=0;
     int res=0;
     for(int i=0;i<n;i++)
     {
        int win=br.nextInt();
        if(win==1 && flag1==1 && flag2==1)
        {
           flag2=0;
           flag3=1;
        }else if(win==1 && flag1==1 && flag3==1)
        {
           flag3=0;
           flag2=1;
        }else if(win==2 && flag2==1 && flag3==1)
        {
           flag3=0;
           flag1=1;
        }else if(win==2 && flag2==1 && flag1==1)
        {
           flag1=0;
           flag3=1;
        }else if(win==3 && flag3==1 && flag1==1)
        {
           flag1=0;
           flag2=1;
        }else if(win==3 && flag3==1 && flag2==1)
        {
           flag2=0;
           flag1=1;
        }else
        {
           res=1;
           break;
        }
     }if(res==0)
     System.out.println("YES");
     else
     System.out.println("NO");
   }
}

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

public class CodeForces {
    public static void main (String[] args) throws IOException {
 Scanner br=new Scanner(System.in);
 int n=br.nextInt();
 int temp=3;
 for(int i=0;i<n;i++){
 	int res=br.nextInt();
 	if(res==temp){
 		System.out.println("NO");
 		System.exit(0);
 	}
 	if(res==1)
 		temp=temp==2?3:2;
 	else if(res==2)
 		temp=temp==1?3:1;
 	else if(res==3)
 		temp=temp==1?2:1;
 }
 System.out.println("YES");
}

}

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

public class C893A {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
	}

	static class Solver {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int t = in.nextInt();
			int[] st = new int[4];
			st[1] = st[2] = 1;
			while(t-- > 0) {
				int w = in.nextInt();
				if(st[w] == 0) {
					System.out.println("NO");
					return;
				}
				for(int i = 1 ; i <= 3 ; i++)
					if(i != w)
						st[i] ^= 1;
			}
			System.out.println("YES");
		}
	}

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), (1<<16));
            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());
        }

    }
}

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

public class CF893A {
	public static void main(String[] arg) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		solver.solve(1, in, out);
		out.close();

	}

	static class Solver {
		private void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();

			int a = 1;
			int b = 2;
			int c = 3;

			int s = c;

			boolean ans = true;

			for (int i = 0; i < n; i++) {
				int r = in.nextInt();
				if (r == s) {
					System.out.println("NO");
					return;
				} else {
					s = 6 - r - s;
				}

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

	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.util.*;
import java.io.*;

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int times = file.nextInt();
		ArrayList<Integer> x= new ArrayList();
		for (int i = 0; i < times; i++) {
			x.add(file.nextInt());
		}
		boolean b = true;
		int curloser = 0;
		for (int i =0; i< times; i++) {
			if (i == 0) {
				if (x.get(i) == 3) {
					b = false;
					break;
				}
				if (x.get(i) == 1) curloser = 2;
				else curloser = 1;
			}
			else {
				if (x.get(i) == curloser) {
					b = false;
					break;
				}
				else {
					if (x.get(i) == 1) {
						if (curloser == 2) curloser = 3;
						else curloser = 2;
					}
					else if (x.get(i) == 2) {
						if (curloser == 3) curloser = 1;
						else curloser = 3;
					}
					else {
						if (curloser == 1) curloser = 2;
						else curloser = 1;
					}
				}
			}
		}
		System.out.println(b ? "YES" : "NO");
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	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;
		}
	}
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
			int games = scan.nextInt();

			int[] wins = new int[games];
			for(int count = 0 ;count < games ; count ++)
				wins[count]= scan.nextInt();

			int p1 = 1, p2 = 2, s=3;
			for(int count = 0 ; count < games ;count++){

				if(wins[count] == s){
					System.out.println("NO");
					break;
				}
				else{
					int temp;
					int temp2;
					if(wins[count]==p1){
						 temp = p2;
						 p2 = s;
					}
					else{
						temp = p1;
						p1 = s;
					}
					s = temp;
				}
				if(count==games-1)
					System.out.println("YES");
			}

	}

}

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

public class A893 {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("cf.in"));

		int n = Integer.parseInt(in.readLine());

		int win = Integer.parseInt(in.readLine());
		if (win == 3) {
			System.out.println("NO"); return;
		}

		int lose = win == 1 ? 2 : 1;

		for (int i = 1; i < n; i++) {
			int next = Integer.parseInt(in.readLine());
			if (next == lose) {
				System.out.println("NO"); return;
			}
			lose = next == win ? 3 - (3 ^ win ^ lose) : win;
			win = next;
		}

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

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;

 /*
 * 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.
 */

/**
 *
 * @author aman_robotics
 */
public class Main
{

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

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

            int winner=0;
            int looser=0;
            int flag=0;
            int play1=1;
            int play2=2;
            if(n!=1){
            for(int i=0;i<n;i++){
                winner=arr[i];
                if(i!=0){
                    if(arr[i]==looser){
                        flag=1;
                        break;
                    }
                    else{
                        if(winner==1){
                            if((play1==2)||(play2==2)){
                                looser=2;
                                play1=winner;
                                play2=3;
                            }
                            else{
                                looser=3;
                                play1=winner;
                                play2=2;
                            }
                        }
                        else if(winner==2){
                            if(play1==1||play2==1){
                                looser=1;
                                play1=winner;
                                play2=3;
                            }
                            else{
                                looser=3;
                                play1=winner;
                                play2=1;
                            }
                        }
                        else{
                            if(play1==1||play2==1){
                                looser=1;
                                play1=winner;
                                play2=2;
                            }
                            else{
                                looser=2;
                                play1=winner;
                                play2=1;
                            }
                        }
                        //System.out.println(play1+" "+play2);
                    }
                }
                else{
                    play1=winner;
                    looser=2;
                    play2=3;
                    //System.out.println(play1+" "+play2);
                }
            }
            if(flag==1)
            System.out.println("NO");
            else
            System.out.println("YES");
            }
            else{
                if(arr[0]==3)
                System.out.println("NO");
                else
                System.out.println("YES");
            }
    }

    static class FastReader{

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }

        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}

import java.util.*;
public class ChessforThree {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		boolean work=true;
		int[] win=new int[n];
		for(int i=0;i<n;i++) {
			win[i]=in.nextInt();
		}
		int spect=3;
		for(int i=0;i<n;i++) {
			if(i==0) {
				if(win[i]==3) {
					work=false;
					break;
				}
			}
			else {
				if(win[i]==spect) {
					work=false;
					break;
				}
			}
			if(win[i]==1) {
				if(spect==2) spect=3;
				else if(spect==3) spect=2;
			}
			else if(win[i]==2) {
				if(spect==1) spect=3;
				else if(spect==3) spect=1;
			}
			else if(win[i]==3) {
				if(spect==1) spect=2;
				else if(spect==2) spect=3;
			}
		}
		if(work) System.out.println("YES");
		else System.out.println("NO");
	}

}

import java.util.*;

public class ChessForThree {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int[] ar = new int[n];
		for(int i=0;i<n;i++){
			ar[i]=scan.nextInt()%3;
		}
		boolean c=true;
		if(ar[0]==3) System.out.println("NO");
		else{

			int cp1 = 1, cp2 = 2;
			for(int i=0; i<n; i++){
				if(ar[i]==cp1){
					cp2=(cp1+cp2)%3;
				}else if(ar[i]==cp2){
					cp1=(cp1+cp2)%3;
				}else{
					c=false;
				}
			}
			System.out.println(c?"YES":"NO");

		}
	}

}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int player1, player2, other;
        int first = in.nextInt();
        if (first == 1) {
            player1 = 1; player2 = 3; other = 2;
        } else {
            player1 = 2; player2 = 3; other = 1;
        }
        for (int i = 1; i < n; i++) {
            int win = in.nextInt();
            if (win == other) {
                System.out.println("NO");
                return;
            }
            player1 = win;
            player2 = swap(other, other = player2);
        }
        System.out.println("YES");
    }
    private static int swap(int a, int b) {
        return a;
    }
}

//package testpackage;

	import java.util.Arrays;
import java.util.Scanner;

	public class Test {

		@Override
		public int hashCode() {
			return 1;
		}

		/*@Override
		public boolean equals(Object arg0) {
			return false;
		}
	*/
		private static int gcd(int a, int b) {
		    int t;
		    while(b != 0){
		        t = a;
		        a = b;
		        b = t%b;
		    }
		    return a;
		}

		private static boolean isrelprime(int a, int b){
			return gcd(a,b) == 1;
		}
		public static void main(String[] args) throws Exception {
			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 s = 1;
			int ss=2;
			int l = 3;

			for(int i=0;i<n;i++){
				if((a[i]==s)){
					int t= l;
					l = ss;
					ss = t;
				}else if(a[i] == ss){
					int t= l;
					l = s;
					ss = t;
				}
				else{
					System.out.println("NO");
					System.exit(0);
				}
			}
			System.out.println("YES");
		}

	}

/**
 * Created by Khoi on 23/11/2017
 * For learning purpose
 */

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class main {
    InputStream is;
    PrintWriter out;
    String INPUT;

    void solve() {
        int n = ni();
        int a = 1, b = 2, c = 3;
        int r = c;
        for (int i = 0; i < n; i++) {
            int e = ni();
            if (e == r) {
                out.println("NO");
                return;
            }
            if (e == a)
                if (r == b)
                    r = c;
                else r = b;
            else if (e == b)
                if (r == a)
                    r = c;
                else r = b;
            else {
                if (r == a)
                    r = b;
                else r = c;
            }
        }
        out.println("YES");
    }

    void run() throws Exception {
        is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
        solve();
        out.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private boolean isEndLine(int c) {
        return c < 32;
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String nsl() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isEndLine(b))) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

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

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    // private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private boolean oj = true;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ChessForThree {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int p1 = sc.nextInt();
        int p2 = 3;
        int spec = p1 == 1 ? 2 : 1;
        boolean poss = true;
        for (int i = 1; i < N; i++) {
            int a = sc.nextInt();
            if (a == spec) {
                poss = false;
                break;
            }
            if (p1 == a) {
                int temp = p2;
                p2 = spec;
                spec = temp;
            }
            else {
                int temp = p1;
                p1 = spec;
                spec = temp;
            }
        }
        out.println(poss ? "YES" : "NO");
        out.close();
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] score = new int[]{1,1,0};
        for(int i=0;i<n;i++){
            int j = scan.nextInt();
            // constant check.
            if(score[j-1]==-1){System.out.println("YES");break;}
            // update who loses and who lost.
            for(int k=0;k<3;k++){
                if(score[k]==-1) score[k]=0;
                if(score[k]==1&&j!=k) score[k]=-1;
            }
            if(i==n-1){System.out.println("NO");}
        }

    }
}

import java.util.Scanner;
//''''
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int Winner1 = 1;
        int Winner2 = 2;
        boolean flag = true;

        for(int i=0;i<n;i++){
            int a = in.nextInt();
            if(Winner1!=a && Winner2!=a){
                flag = false;
                break;
            }
            else{
                Winner1 = a;
                Winner2 = 6 - a - Winner2;
            }
        }
        if(flag){
            System.out.print("YES");
        }
        else{
            System.out.print("NO");
        }
    }
}

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

public class CF893A {
	public static void main(String[] arg) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solver solver = new Solver();
		solver.solve(1, in, out);
		out.close();

	}

	static class Solver {
		private void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();

			boolean a = true;
			boolean b = true;
			boolean c = false;

			boolean ans = true;

			for (int i = 0; i < n; i++) {
				int r = in.nextInt();
				if (a && b && (r == 1)) {
					a = true;
					b = false;
					c = true;
				} else if (a && b && (r == 2)) {
					a = false;
					b = true;
					c = true;
				} else if (b && c && (r == 2)) {
					a = true;
					b = true;
					c = false;
				} else if (b && c && (r == 3)) {
					a = true;
					b = false;
					c = true;
				} else if (a && c && (r == 3)) {
					a = false;
					b = true;
					c = true;
				} else if (a && c && (r == 1)) {
					a = true;
					b = true;
					c = false;
				} else {
					ans = false;
					out.println("NO");
				}
			}
			if (ans)
				out.println("YES");
		}
	}

	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.InputStreamReader;

public class chess4three {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		boolean possible = true;
		boolean alex = true;
		boolean bob = true;
		boolean carl = false;
		for (int i = 0; i < n; i++) {
			int winner = Integer.parseInt(reader.readLine());
			if (winner == 1 && !alex || winner == 2 && !bob || winner == 4 && !carl) {
				possible = false;
				break;
			}
			if (winner == 1) {
				if (bob) {
					bob = false;
					carl = true;
				} else {
					carl = false;
					bob = true;
				}

			} else if (winner == 2) {
				if (carl) {
					carl = false;
					alex = true;
				} else {
					alex = false;
					carl = true;
				}
			} else {
				if (alex) {
					alex = false;
					bob = true;
				} else {
					bob = false;
					alex = true;
				}
			}
		}
		System.out.println(possible ? "YES" : "NO");
	}
}

import java.util.Scanner;

public class codeforces {

    public static void main(String[] args) {
        TaskA Solver = new TaskA();
        Solver.Solve();
    }

    public static class TaskA {
        public void Solve() {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int last = in.nextInt();
            int p1, p2, w;
            if (last == 1) {
                p1 = 1;
                p2 = 3;
                w = 2;
            }
            else {
                p1 = 2;
                p2 = 3;
                w = 1;
            }
            boolean fl = true;
            for (int i = 1; i < n; i++) {
                int cur = in.nextInt();
                if (cur == w) {
                    fl = false;
                    break;
                }
                else {
                    p1 = cur;
                    int t = p2;
                    p2 = w;
                    w = t;
                }
            }
            System.out.println(fl ? "YES" : "NO");
        }
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;

 /*
 * 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.
 */

/**
 *
 * @author aman_robotics
 */
public class Main
{

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

            int n=in.nextInt();
            int arr[]=new int[n+1];
            for(int i=0;i<n;i++){
                arr[i]=in.nextInt();
            }
            boolean a=true;
            boolean b=true;
            boolean c=false;
            int winner=0;
            int looser=0;
            int flag=0;
            for(int i=0;i<n;i++){
                if(i==0){
                    if(arr[i]==1){
                        winner=1;
                        looser=2;
                        b=false;
                    }
                    else{
                        winner=2;
                        looser=1;
                        a=false;
                    }
                    c=true;

                    //System.out.println(looser);
                }
                else{
                    if(arr[i]==looser){
                        flag=1;
                        break;
                    }
                    else{
                        winner=arr[i];
                        if(winner==1){
                            if(!b){
                                b=true;
                                looser=3;
                            }
                            else{
                                c=true;
                                looser=2;
                            }
                        }
                        else if(winner==2){
                            if(!a){
                                a=true;
                                looser=3;
                            }
                            else{
                                c=true;
                                looser=1;
                            }
                        }
                        else{
                            if(!b){
                                b=true;
                                looser=1;
                            }
                            else{
                                a=true;
                                looser=2;
                            }
                        }
                        //System.out.println(looser);
                    }
                }

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

    }

    static class FastReader{

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }

        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}

import java.util.*;

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

		int n = kbd.nextInt();
		int count = 0;

		for(int j = 0; j < n; j++){
			int x = kbd.nextInt();
			if(x== n) {
				count++;
			}
			n = 6 - x - n;
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

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

	static Scanner scr=new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		int t=scr.nextInt();
//		while(t-->0) {
			solve();
			System.out.println();
//		}
	}
	static void solve() {
		int n=scr.nextInt();
		int p1=1;
		int p2=2;
		for(int i=0;i<n;i++) {
			int w=scr.nextInt();
			if(w!=p1 ||w!=p2) {
				System.out.print("NO");
				return;
			}
			for(int j=1;j<=3;j++) {
				if(p1!=j && p2!=j) {
					p2=j;
				}
			}
			p1=w;
		}
		System.out.print("YES");
	}
}

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

public class A {
    public static void main(String[] args){
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        int streak = 0;
        int old = fr.nextInt();
        boolean print = true;
        for (int i = 0; i < n-1; i++) {
            int temp = fr.nextInt();
            if(temp==old){
                streak++;
            } else if(temp!=(streak+old)%3){
                System.out.println("NO");
                print = false;
                break;
            }
        }
        if(print){
            System.out.println("YES");
        }
    }
    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;
        }
    }
}

import java.util.Scanner;

public class a {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int loser = 3;
		for(int i = 0; i < n; i++) {
			int t = in.nextInt();
			if(t == loser) {
				System.out.println("NO");
				return;
			}
			for(int j = 1; j < 4; j++) {
				if(j != t && j != loser) {
					loser = j;
					break;
				}
			}
			System.out.println(loser);
		}
		System.out.println("YES");
	}
}

import java.util.*;
import java.util.Map.Entry;

import javax.lang.model.util.ElementScanner6;

import java.util.*;

import java.io.*;

 public class FasterReader {
BufferedReader br;
StringTokenizer st;

public FasterReader() {
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;

}
static long sum(int n){
    if(n==0){
        return 0;
    }
    if(n%2==0){
      return   n/=2;
    }
    else
return -n+sum(n-1);

}
static void power(int I[][],int a[][],int dem){
    //matrix multiplication
 int res[][]=new int[dem][dem];
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         for(int k=0;k<dem;++k){
             res[i][j]+=a[i][k]*I[k][j];
         }
     }
 }
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         I[i][j]=res[i][j];
     }
 }

}
public static void multiply(int a[][],int number){
   int I[][]={
       {1,0},
       {0,1},

   };
   for(int i=0;i<=number;++i){
        power(I,a,2);
   }

   for(int i=0;i<a.length;++i){
    for(int j=0;j<a[0].length;++j){
        System.out.print(I[i][j]+" ");
    }
    System.out.println();
}

}
static int avg(int a[]){
    int  sum=0;
    for(int i=0;i<a.length;++i){
        sum+=a[i];
    }
    return Math.round((float)sum/a.length);
}
static int[] seive(int max){
    int length[]=new int[max+1];
    for(int i=2;i<=max;++i){
        length[i]=i;
    }
    for(int i=2;i<=max;i+=2){
        length[i]=2;
    }
    for(int i=3;i<=Math.sqrt(max);++i){
        if(length[i]==i){
             for(int j=i*i;j<=max;j+=i){
                 if(length[j]==j){
                     length[j]=i;
                 }
             }
        }
    }
return length;

}
static ArrayList<Integer> factor(long n){

  int length[]=seive((int)n);
  ArrayList<Integer>A=new ArrayList<>();
  while(n!=1){
      A.add(length[(int)n]);
      n=n/length[(int)n];

  }

  return A;

}

public static void main(String[] args) {
FasterReader scan=new FasterReader();
int  n=scan.nextInt();
ArrayList<Integer>A=new ArrayList<>();
for(int i=0;i<n;++i){
    A.add(scan.nextInt());
}
if(n<=2){
    System.out.println("YES");
}
else{
if(A.contains(1)&&A.contains(2)&&A.contains(3)){
System.out.println("NO");
}
else
System.out.println("YES");
}
}
 }

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] log = new int[n];
        int index = 0;
        boolean flag = true;
        for(int i=0;i<n;i++){
            log[i] = scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if((log[1]==2&&log[0]==1)||(log[1]==1&&log[0]==2)){flag=false;}
            if(i+1<n&&i-1>0){
                if(log[i+1]==log[i-1]&&log[i+1]!=log[i]&&log[i-1]!=log[i]){flag=false; index = i;}
            }
        }
        System.out.println(index);
        if(flag) System.out.println("YES");
        else{System.out.println("NO");}
    }
}

import java.util.Scanner;

public class a {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int loser = 3;
		for(int i = 0; i < n; i++) {
			int t = in.nextInt();
			if(t == loser) {
				System.out.println("No");
				return;
			}
			for(int j = 1; j < 4; j++) {
				if(j != t && j != loser) {
					loser = j;
					break;
				}
			}
			System.out.println(loser);
		}
		System.out.println("Yes");
	}
}

import java.util.*;

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

		int n = kbd.nextInt();

		int[] ar = new int[n];

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

		int count = 0;

		for(int j = 0; j < ar.length; j++){
			if(ar[j] == n) {
				count++;
				n = 6 - ar[j] - n;
			} else {
				n = 6 - ar[j] - n;
			}
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    MyScanner2 in=new MyScanner2(System.in);
	    int w=0,l=0,c=3,d=1;
	    int n=in.nextInt();
	    w=in.nextInt();
	    --n;
	    if(w==3)
	    {
	        d=0;
	    }
	    else
	    {
	        if(w==1)
	        {
	            c=2;
	            l=3;
	        }
	        else if(w==2)
	        {
	            l=3;
	            c=l;
	        }
	    }
	    while(n>0)
	    {
	        n--;
	        int ww=in.nextInt();
	        if(d==0)
	        {
	            continue;
	        }

	        if(ww==c)
	        {
	            d=0;
	            continue;
	        }

	        if(ww==l)
	        {
	            int tmp=c;
	            c=w;
	            w=tmp;

	            tmp=w;
	            w=l;
	            l=tmp;

	        }
	        else
	        {
	            int tmp=c;
	            c=l;
	            l=tmp;
	        }
	    }

		if(d==0)
		{
		    System.out.println("NO");
		}
		else
		{
		    System.out.println("YES");
		}

	}
}

class MyScanner2
{
   final private int BUFFER_SIZE = 1 << 16;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public MyScanner2(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }

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

   //reads in the next string
   public String next() throws Exception
   {
      StringBuilder ret =  new StringBuilder();
      byte c = read();
      while (c <= ' ') c = read();
      do
      {
         ret = ret.append((char)c);
         c = read();
      } while (c > ' ');
      return ret.toString();
   }

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

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

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

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ChessForThree {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int p1 = sc.nextInt();
        int p2 = 3;
        int spec = p1 == 1 ? 2 : 1;
        boolean poss = true;
        for (int i = 1; i < N; i++) {
            int a = sc.nextInt();
            if (p1 == a) {
                int temp = p2;
                p2 = spec;
                spec = temp;
            }
            else if (p2 == a) {
                int temp = p1;
                p1 = spec;
                spec = temp;
            }
            else {
                poss = false;
            }
        }
        out.println(poss ? "YES" : "NO");
        out.close();
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

import java.util.*;
import java.util.Map.Entry;

import javax.lang.model.util.ElementScanner6;

import java.util.*;

import java.io.*;

 public class FasterReader {
BufferedReader br;
StringTokenizer st;

public FasterReader() {
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;

}
static long sum(int n){
    if(n==0){
        return 0;
    }
    if(n%2==0){
      return   n/=2;
    }
    else
return -n+sum(n-1);

}
static void power(int I[][],int a[][],int dem){
    //matrix multiplication
 int res[][]=new int[dem][dem];
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         for(int k=0;k<dem;++k){
             res[i][j]+=a[i][k]*I[k][j];
         }
     }
 }
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         I[i][j]=res[i][j];
     }
 }

}
public static void multiply(int a[][],int number){
   int I[][]={
       {1,0},
       {0,1},

   };
   for(int i=0;i<=number;++i){
        power(I,a,2);
   }

   for(int i=0;i<a.length;++i){
    for(int j=0;j<a[0].length;++j){
        System.out.print(I[i][j]+" ");
    }
    System.out.println();
}

}
static int avg(int a[]){
    int  sum=0;
    for(int i=0;i<a.length;++i){
        sum+=a[i];
    }
    return Math.round((float)sum/a.length);
}
static int[] seive(int max){
    int length[]=new int[max+1];
    for(int i=2;i<=max;++i){
        length[i]=i;
    }
    for(int i=2;i<=max;i+=2){
        length[i]=2;
    }
    for(int i=3;i<=Math.sqrt(max);++i){
        if(length[i]==i){
             for(int j=i*i;j<=max;j+=i){
                 if(length[j]==j){
                     length[j]=i;
                 }
             }
        }
    }
return length;

}
static ArrayList<Integer> factor(long n){

  int length[]=seive((int)n);
  ArrayList<Integer>A=new ArrayList<>();
  while(n!=1){
      A.add(length[(int)n]);
      n=n/length[(int)n];

  }

  return A;

}

public static void main(String[] args) {
FasterReader scan=new FasterReader();
int  n=scan.nextInt();
ArrayList<Integer>A=new ArrayList<>();
for(int i=0;i<n;++i){
    A.add(scan.nextInt());
}
if(n<=2){
    System.out.println("YES");
}
else{
if(A.contains(1)&&A.contains(2)&&A.contains(3)){
System.out.println("YES");
}
else
System.out.println("NO");
}
}
 }

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

public class A {
    public static void main(String[] args){
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        int streak = 1;
        int old = fr.nextInt();
        boolean print = true;
        for (int i = 0; i < n-1; i++) {
            int temp = fr.nextInt();
            if(temp==old){
                streak++;
            } else if(temp!=(streak+old)%3+1){
                System.out.println("NO");
                print = false;
                break;
            }
            old = temp;
        }
        if(print){
            System.out.println("YES");
        }
    }
    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;
        }
    }
}

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] score = new int[]{1,1,0};
        for(int i=0;i<n;i++){
            int j = scan.nextInt();
            if((score[j-1]==-1)||(j==2&&i==0)){System.out.println("NO");break;}
            for(int k=0;k<3;k++){if(score[k]==-1) score[k]=0;}
            for(int k=0;k<3;k++){if(score[k]==1&&j-1!=k) score[k]=-1;}
            if(i==n-1){System.out.println("YES");}
        }
    }
}

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

public class Solution{
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	int n;
	int[] arr;
	public void solve(){
		n=ni();
		arr=na(n);

		boolean flag=false;
		TreeSet<Integer> ts=new TreeSet<Integer>();
		ts.add(1);
		ts.add(2);
		int i;
		for(i=1;i<=n;i++){
			if(!ts.contains(arr[i-1]))break;
			int sum=0;
			for(Integer itr: ts){
				sum=sum+itr;
			}
			ts.clear();
			ts.add(arr[i-1]);
			ts.add(6-sum);
			//out.println(ts);
		}
		if(i==n+1){
			flag=true;
		}

		ts=new TreeSet<Integer>();
		ts.add(1);
		ts.add(3);
		for(i=1;i<=n;i++){
			if(!ts.contains(arr[i-1]))break;
			int sum=0;
			for(Integer itr: ts){
				sum=sum+itr;
			}
			ts.clear();
			ts.add(arr[i-1]);
			ts.add(6-sum);
			//out.println(ts);
		}
		if(i==n+1){
			flag=true;
		}

		ts=new TreeSet<Integer>();
		ts.add(3);
		ts.add(2);
		for(i=1;i<=n;i++){
			if(!ts.contains(arr[i-1]))break;
			int sum=0;
			for(Integer itr: ts){
				sum=sum+itr;
			}
			ts.clear();
			ts.add(arr[i-1]);
			ts.add(6-sum);
			//out.println(ts);
		}

		if(flag==true)out.println("YES");
		else out.println("NO");
	}

	void run(){
		is = new DataInputStream(System.in);
		out = new PrintWriter(System.out);
		int t=1;while(t-->0)solve();
		out.flush();
	}
	public static void main(String[] args)throws Exception{new Solution().run();}
	//Fast I/O code is copied from uwi code.
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private int readByte(){
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	private String ns(){
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	private char[] ns(int n){
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	private char[][] nm(int n, int m){
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	private int[] na(int n){
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	private int ni(){
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	private long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	static  int i(long x){return (int)Math.round(x);}
	static class Pair implements Comparable<Pair>{
		long fs,sc;
		Pair(long a,long b){
			fs=a;sc=b;
		}
		public int compareTo(Pair p){
			if(this.fs>p.fs)return 1;
			else if(this.fs<p.fs)return -1;
			else{
				return i(this.sc-p.sc);
			}
			//return i(this.sc-p.sc);
		}
		public String toString(){
			return "("+fs+","+sc+")";
		}
	}

}

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

public class A
{

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

        //START//
        int n = in.nextInt();
        int wi=1,ch=2,ob=3;
        boolean consistent = true;
        for (i = 0; i < n; i++)
        {
            int res = in.nextInt();
            if (res == wi || res == ch)
            {
                wi = res;
                int temp = ch;
                ch = ob;
                ob = temp;

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

        //END

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

    public static void main(String[] args)
    {
        new A().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++];
        }
    }
}

/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ChessForThree {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int p1 = sc.nextInt();
        int p2 = 3;
        int spec = p1 == 1 ? 2 : 1;
        boolean poss = true;
        for (int i = 1; i < N; i++) {
            int a = sc.nextInt();
            if (a == spec) {
                poss = false;
                break;
            }
            p1 = a;
            int temp = p2;
            p2 = spec;
            spec = temp;
        }
        out.println(poss ? "YES" : "NO");
        out.close();
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}

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

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int times = file.nextInt();
		ArrayList<Integer> x= new ArrayList();
		for (int i = 0; i < times; i++) {
			x.add(file.nextInt());
		}
		boolean b = true;
		int curloser = 0;
		for (int i =0; i< times; i++) {
			if (i == 0) {
				if (x.get(0) == 3) {
					b = false;
					break;
				}
				if (x.get(i) == 1) curloser = 2;
				else curloser = 1;
			}
			else {
				if (x.get(i) == curloser) {
					b = false;
					break;
				}
				else {
					if (x.get(i) == 1) {
						if (curloser == 2) curloser = 3;
						else curloser = 2;
					}
					else if (x.get(i) == 2) {
						if (curloser == 3) curloser = 1;
						else curloser = 3;
					}
					else {
						if (curloser == 1) curloser = 3;
						else curloser = 1;
					}
				}
			}
		}
		System.out.println(b ? "YES" : "NO");
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	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;
		}
	}
}

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

public class ChessForThree {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(br.readLine());
        }

        int w=1, l=2, s=3;
        for(int i=0; i<n; i++){
            if(a[i] == s){
                System.out.println("NO");
                return;
            } else {
                w = a[i];
                int temp = s;
                s = l;
                l = temp;
            }
        }
        System.out.println("YES");
    }
}

import java.util.*;

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

		int n = kbd.nextInt();

		int[] ar = new int[n];

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

		int count = 0;

		for(int j = 0; j < ar.length; j++){
			if(ar[j] == n) {
				count++;
			}
			n = 6 - ar[j] - n;
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

/**
 * Created by Khoi on 23/11/2017
 * For learning purpose
 */

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class main {
    InputStream is;
    PrintWriter out;
    String INPUT;

    void solve() {
        int n = ni();
        int a = 1, b = 2, c = 3;
        int r = c;
        for (int i = 0; i < n; i++) {
            int e = ni();
            if (e == r) {
                out.println("NO");
                return;
            }
            if (e == a)
                if (r == b)
                    r = c;
                else r = b;
            else if (e == b)
                if (r == a)
                    r = c;
                else r = b;
            else {
                if (r == a)
                    r = b;
                else r = a;
            }
        }
        out.println("YES");
    }

    void run() throws Exception {
        is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
        solve();
        out.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private boolean isEndLine(int c) {
        return c < 32;
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String nsl() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isEndLine(b))) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

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

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    // private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private boolean oj = true;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}

		//~~~~~~~~~~~~~~~~~~~~~~~@@@@@@@@@@@@@@@_____________K_____S_____J__________@@@@@@@@@@@@@@@@@@@@@@@@@@@@~~~~~~~~~~~~~~~~~~~~~~~~~~
		//Date:00/00/17
		//-------------

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

public class force1_442{

	static Parser sc=new Parser(System.in);
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	public static void main(String[] args) throws IOException {
		// use ((((((( sc ............... for input

		int n=sc.nextInt();
        int a=1,b=2;
        boolean f=false;
        int c=3,lastLoss=0;

        while(n-->0){

            int t=sc.nextInt();

            if(t==a){

                if(c>3){

                  if(a==1){
                    c=2;
                  }
                  else {
                    c=1;
                  }
                }

                b=c;
            }
            else if(t==b){

                if(c>3){

                  if(b==1){
                    c=2;
                  }
                  else {
                    c=1;
                  }
                }

                a=c;

            }
            else{
             f=true;
            }

            c++;

        }

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

	}

	//___________________________Fast-Input_Output-------------------*******************

	static class Parser {
        final private int BUFFER_SIZE = 1 << 20;  // 2^16, a good compromise for some problems
        private InputStream din;    // Underlying input stream
        private byte[] buffer;      // Self-maintained buffer
        private int bufferPointer;  // Current read position in the buffer
        private int bytesRead;      // Effective bytes in the buffer read from the input stream
        private SpaceCharFilter filter;
        public Parser(InputStream in) {
            din = in;
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;

        }

        /**
         * Read the next integer from the input stream.
         * @return The next integer.
         * @throws IOException
         */
        public int nextInt() throws IOException {
            int result = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
				while (c >= '0' && c <= '9') {
                result = result * 10 + c - '0';
                c = read();
            }
			if (neg) return -result;
            	return result;
        }

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

        public String nextLine()throws IOException {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = read();
				} while (!isEndOfLine(c)==true);
				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);
			}

        /**
         * Read the next byte of data from the input stream.
         * @return the next byte of data, or -1 if the end of the stream is reached.
         * @throws IOException if an I/O error occurs.
         */
        public byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        /**
         * Read data from the input stream into the buffer
         * @throws IOException if an I/O error occurs.
         */
        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }
    }
}

/*

#include<bits/stdc++.h>
using namespace std;
int A[1000000]={0};
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     int n,q,l,r,f=0;
     cin>>n>>q>>l>>r;
     while(q--)
     {
        int a;
        cin>>a;
        if(a==1)
       {
          f++;

            int b,c;
            cin>>b>>c;
            A[b-1]=c;

       }
       else
       {
        int b,c;
        cin>>b>>c;
        b--;
        c--;
        long long int sum=0,z=0,nz=0;

        if(!f)
        {
            cout<<0<<'\n';
            continue;
        }

        for(int i=b;i<=c;i++)
        {
            if(A[i]>r)
            {
                sum+=(nz*(nz+1)/2);
                while(A[i]>r&&i<=c)
                i++;

                i--;
                nz=0;
            }
            else if(A[i]<l)
            {
                z=0;
                while(A[i]<l&&i<=c)
                i++,z++,nz++;

                i--;
                if(i!=c)
                sum-=(z*(z+1)/2);
                else
                sum+=(nz*(nz+1)/2),sum-=(z*(z+1)/2);
            }
            else{
                nz++;
            if(i==c)
              sum+=(nz*(nz+1)/2);

            }
        }
            cout<<sum<<'\n';
        }
       }
       return 0;
     }0
0
0

*/

import java.util.Scanner;

public class codeforces {

    public static void main(String[] args) {
        TaskA Solver = new TaskA();
        Solver.Solve();
    }

    public static class TaskA {
        public void Solve() {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int last = in.nextInt();
            int p1 = 0, p2 = 0, w = 0;
            boolean fl = true;
            if (last == 1) {
                p1 = 1;
                p2 = 3;
                w = 2;
            }
            else {
                if (last == 2) {
                    p1 = 2;
                    p2 = 3;
                    w = 1;
                }
                else
                    fl = false;
            }
            for (int i = 1; i < n; i++) {
                int cur = in.nextInt();
                if (cur == w) {
                    fl = false;
                    break;
                }
                else {
                    p1 = cur;
                    int t = p2;
                    p2 = w;
                    w = t;
                }
            }
            System.out.println(fl ? "YES" : "NO");
        }
    }
}

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

public class Rough{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;

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

		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}

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

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

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

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

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) (1e6+1);
    public static long[] Bit;
    public static List<Integer>[] edges;
	public static int[][] parent;
	public static int col = 20;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
		int n = sc.nextInt();
		boolean found = false;
		int[] game = new int[n];
		for(int i=0;i<n;++i) game[i] = sc.nextInt();
		if(game[0] == 3) {
			found = play(game,new int[] {3,1,2}) | play(game,new int[] {3,1,2});
		}else found = play(game,new int[] {1,2,3});
		if(found) out.print("YES");
		else out.print("NO");

		out.close();

	}
	private static boolean play(int[] game, int[] a) {
		boolean found = true;
		for(int i=0;i<game.length && found;++i) {
			if(game[i] == 1) {
				if(a[2] == 1) found = false;
				else {
					if(a[1] != 1) {
					int temp = a[1];
					a[1] = a[2];
					a[2] = temp;
					}else {
						int temp = a[0];
						a[0] = a[2];
						a[2] = temp;
					}
				}
			}else if(game[i] == 2) {
				if(a[2] == 2) found = false;
				else {
					if(a[1] != 2) {
					int temp = a[1];
					a[1] = a[2];
					a[2] = temp;
					}else {
						int temp = a[0];
						a[0] = a[2];
						a[2] = temp;
					}
				}
			}else {
				if(a[2] == 3) found = false;
				else {
					if(a[1] != 3) {
					int temp = a[1];
					a[1] = a[2];
					a[2] = temp;
					}else {
						int temp = a[0];
						a[0] = a[2];
						a[2] = temp;
					}
				}
			}
		}
		return found;
	}

}

import java.util.Scanner;

/**
 *
 * @author rn-sshawish
 */
public class Solutions {

    public static void main(String[] args) {

        int notPlay = 3;
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        for (int i = 0; i < n; i++) {
            int win = input.nextInt();
            if (win == notPlay) {
                System.out.println("NO");
                break;
            }
            notPlay = getNotPlay(win, notPlay);
        }
    }

    public static int getNotPlay(int win, int previousNotPlay) {
        if (win == 1 && previousNotPlay == 3) {
            return 2;
        } else if (win == 2 && previousNotPlay == 3) {
            return 1;
        } else if (win == 1 && previousNotPlay == 2) {
            return 3;
        } else if (win == 3 && previousNotPlay == 2) {
            return 1;
        } else if (win == 2 && previousNotPlay == 1) {
            return 3;
        } else {
            return 2;
        }

    }
}

import java.util.*;

public class x{

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

               int n=sc.nextInt();

               while(n-->0){
                       int t=sc.nextInt();
                       int f=1,s=2,lt=3;

                       if(t==lt){
                               System.out.println("NO");
                               return ;
                       }
                       else if(t==f){
                               swap(s,lt);
                       }
                       else if(t==s){
                               swap(f,lt);
                       }
               }

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

       public static void swap(int a,int b){
               int te=a;
               a=b;
               b=te;
       }
}

import java.util.Scanner;

public class ChessForThree {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int temp=1,a=1,b=2,spec=3;
        int ans=sc.nextInt();
        //temp=ans;
        if(ans==a || ans==b){
            for(int i=0;i<n-1;i++){
                a=ans;
                b=b+spec;
                spec=b-spec;
                b=b-spec;
                ans=sc.nextInt();
                if(ans==a || ans==b){
                    temp+=1;
                }
                else{
                    System.out.println("No");
                    break;
                }
            }
            if(temp==n){
                System.out.println("Yes");
            }
        }
        else{
            System.out.println("No");
        }
    }
}

import java.util.Scanner;
public class chess
{
    public static void main(String args[])
    {
        Scanner s= new Scanner(System.in);
        int n= s.nextInt();
        int a[]= new int[n];
        int x= 1, y=2, z=3, i, t, count=0;
        for(i=0; i<n; i++)
        {
            a[i]= s.nextInt();
            if(a[i]==x)
            {
                t=y;
                y=z;
                z=t;
            }
            else if(a[i]==y)
            {
                t=x;
                x=z;
                x=t;
            }
            else if(a[i]==z)
            {
                System.out.println("NO");
                break;
            }
            count++;
        }
        if(count==n)
        System.out.println("YES");
    }
}

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

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

     // public static void solve(){

     //    FastScanner sc = new FastScanner();
     //    sb = new StringBuilder();
     //    int n = sc.nextInt();
     //    int m = sc.nextInt();
     //    map = new HashMap<>();

     //    for(int i = 0 ; i < n ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        map.put(b,a);
     //    }
     //    for(int i = 0 ; i < m ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        sb.append(a+" "+b+" #"+map.get(b.substring(0,b.length()-1))+"\n");
     //    }

     //    System.out.println(sb);

     // }

     public static boolean solve(){

        int player1 = 1;
        int player2 = 2;
        int not = -1;
        for(int i = 0 ; i < n ; i++){
            if(arr[i] == not)
                return false;
            if(arr[i] == player1){
                not = player2;
                if(player2 != 1 && arr[i] != 1)
                    player2 = 1;
                else if(player2 != 2 && arr[i] != 2)
                    player2 = 2;
                else player2 = 3;
            }
            else{
                not = player1;
                if(player1 != 1 && arr[i] != 1)
                    player1 = 1;
                else if(player1 != 2 && arr[i] != 2)
                    player1 = 2;
                else player1 = 3;
            }
        }

        return true;
     }

     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){

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

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

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

                // m = sc.nextInt();

                // k = sc.nextLong();
                // 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();
                }

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

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

                // mat = new Character[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());
                }
        }

}

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

public class aaaaaaaaaaaaaaaa {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int times = file.nextInt();
		ArrayList<Integer> x= new ArrayList();
		for (int i = 0; i < times; i++) {
			x.add(file.nextInt());
		}
		boolean b = true;
		int curloser = 0;
		for (int i =0; i< times; i++) {
			if (i == 0) {
				if (x.get(i) == 1) curloser = 2;
				else curloser = 1;
			}
			else {
				if (x.get(i) == curloser) {
					b = false;
					break;
				}
				else {
					if (x.get(i) == 1) {
						if (curloser == 2) curloser = 3;
						else curloser = 2;
					}
					else if (x.get(i) == 2) {
						if (curloser == 3) curloser = 1;
						else curloser = 3;
					}
					else {
						if (curloser == 1) curloser = 3;
						else curloser = 1;
					}
				}
			}
		}
		System.out.println(b ? "YES" : "NO");
	}

	public static void main(String[] args) throws Exception {
		new aaaaaaaaaaaaaaaa().run();
	}

	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;
		}
	}
}

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

public class chess4three {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		boolean possible = true;
		boolean alex = true;
		boolean bob = true;
		boolean carl = false;
		for (int i = 0; i < n; i++) {
			int winner = Integer.parseInt(reader.readLine());
			if (winner == 1 && !alex || winner == 2 && !bob || winner == 4 && !carl) {
				possible = false;
				break;
			}
			if (winner == 1) {
				if (bob) {
					bob = false;
					carl = true;
				} else {
					carl = false;
					bob = true;
				}

			} else if (winner == 2) {
				if (carl) {
					carl = false;
					alex = true;
				} else {
					alex = false;
					carl = true;
				}
			} else {
				if (alex) {
					alex = false;
					bob = true;
				} else {
					bob = false;
					alex = true;
				}
			}
		}
		System.out.println(possible ? "YES" : "NO");
	}
}

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    MyScanner2 in=new MyScanner2(System.in);
	    int w=0,l=0,c=3,d=1;
	    int n=in.nextInt();
	    w=in.nextInt();
	    --n;
	    if(w==3)
	    {
	        d=0;
	    }
	    else
	    {
	        if(w==1)
	        {
	            c=2;
	            l=3;
	        }
	        else if(w==2)
	        {
	            l=3;
	            c=1;
	        }
	    }
	    while(n>0)
	    {
	        n--;
	        int ww=in.nextInt();
	        if(d==0)
	        {
	            continue;
	        }

	        if(ww==c)
	        {
	            d=0;
	            continue;
	        }

	        if(ww==l)
	        {
	            int tmp=c;
	            c=w;
	            w=tmp;

	            tmp=w;
	            w=l;
	            l=tmp;

	        }
	        else
	        {
	            int tmp=c;
	            c=l;
	            l=c;
	        }
	    }

		if(d==0)
		{
		    System.out.println("NO");
		}
		else
		{
		    System.out.println("YES");
		}

	}
}

class MyScanner2
{
   final private int BUFFER_SIZE = 1 << 16;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public MyScanner2(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }

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

   //reads in the next string
   public String next() throws Exception
   {
      StringBuilder ret =  new StringBuilder();
      byte c = read();
      while (c <= ' ') c = read();
      do
      {
         ret = ret.append((char)c);
         c = read();
      } while (c > ' ');
      return ret.toString();
   }

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

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

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

import java.util.Scanner;

public class AAA {
public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int n=sc.nextInt();
	int x=1,y=2;
	for (int i = 1; i <=n; i++) {
		int aa=sc.nextInt();
//		System.out.println(x+" "+y+" "+aa);
		if(x==aa){
			if(y==1&&x==2){y=3;continue;}
			if(y==1&&x==3){y=2;continue;}
			if(y==2&&x==3){y=1;continue;}
			if(y==2&&x==1){y=3;continue;}
			if(y==3&&x==1){y=2;continue;}
			if(y==3&&x==2){y=1;continue;}
		}else if(y==aa){
			if(y==1&&x==2){y=3;continue;}
			if(y==1&&x==3){y=2;continue;}
			if(y==2&&x==3){y=1;continue;}
			if(y==2&&x==1){y=3;continue;}
			if(y==3&&x==1){y=2;continue;}
			if(y==3&&x==2){y=1;continue;}
		}else{
			System.out.println("NO");
			return;
		}
	}
	System.out.println("YES");

	}
}

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

public class Main {
    static Reader in;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        in = new Reader();
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        new Solution();
        out.close();
    }

    static class Solution {
        Solution() {
            int n = in.nextInt();
            int[] games = new int[n];
            for(int i=0; i<n; i++) {
                games[i] = in.nextInt();
            }

            int alex = 0;
            int bob = 0;
            int carl = 0;

            if(games[0]==1)
                ++bob;
            else if(games[0]==2)
                ++alex;

            boolean flag = false;
            for(int i=1; i<n; i++) {
                if(bob>1 || carl>1 || alex>1) {
                    flag = true;
                    break;
                }
                if(bob!=0 && carl==0 && alex==0) {
                    if(bob>1 || carl>1 || alex>1) {
                        flag = true;
                        break;
                    } else if(bob==1 && games[i]==2) {
                        flag = true;
                        break;
                    } else {
                        if(games[i]==3) {
                            --bob;
                            ++alex;
                        } else if(games[i]==1) {
                            --bob;
                            ++carl;
                        }
                    }
                } else if(alex!=0 && bob==0 && carl==0) {
                    if(bob>1 || carl>1 || alex>1) {
                        flag = true;
                        break;
                    } else if(alex==1 && games[i]==1) {
                        flag = true;
                        break;
                    } else {
                        if(games[i]==2) {
                            --alex;
                            ++carl;
                        } else if(games[i]==3) {
                            --alex;
                            ++bob;
                        }
                    }
                } else if(carl!=0 && bob==0 && alex==0) {
                    if(bob>1 || carl>1 || alex>1) {
                        flag = true;
                        break;
                    } else if(carl==1 && games[i]==3) {
                        flag = true;
                        break;
                    } else {
                        if(games[i]==1) {
                            --carl;
                            ++bob;
                        } else if(games[i]==2) {
                            --carl;
                            ++alex;
                        }
                    }
                }
            }
            if(flag)
                out.println("NO");
            else
                out.println("YES");
        }
    }

    static class Reader {
        public BufferedReader br;
        public StringTokenizer st;
        public Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));

        }
        public String next() {
            while(st==null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public char nextChar() {
            return next().charAt(0);
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}

import java.util.*;

public class A893 {

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

		int n=sc.nextInt(), winner=-1, loser=-1, player=-1, w=-1;
		boolean flag=true;
		for(int i=0; i<n; i++)
		{
			if(i==0)
			{
				winner=sc.nextInt();
				if(winner==1)
				{
					loser=2;
					w=1;
				}
				else
				{
					loser=1;
					w=2;
				}
				player=3;
			}
			else
			{
				winner=sc.nextInt();
				if(winner==loser)
				{
					flag=false;
					break;
				}
				else
				{
					if(winner==player)
					{
						int tmp=loser;
						loser=w;
						w=player;
						player=tmp;
					}
					else if(winner==w)
					{
						int tmp=loser;
						loser=player;
						player=tmp;
					}
				}
			}

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

	}
}

import java.util.Scanner;

public class a {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int loser = 3;
		for(int i = 0; i < n; i++) {
			int t = in.nextInt();
			if(t == loser) {
				System.out.println("No");
				return;
			}
			for(int j = 1; j < 4; j++) {
				if(j != t && j != loser) {
					loser = j;
					break;
				}
			}
			System.out.println(loser);
		}
		System.out.println("Yes");
	}
}

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

public class A {
	public static void main(String[] args) throws IOException {
		//Scanner sc = new Scanner(new File("A.txt"));
		Scanner sc = new Scanner(System.in);

		int nTests = sc.nextInt();

		boolean possible = true;
		int spectator = 3;
		for (int i=0; i < nTests; i++) {
			int winner = sc.nextInt();

			if (spectator == winner) {
				possible = false;
				break;
			}

			if (winner == 1) {
				spectator = (spectator == 3) ? 2 : 1;
			} else if (winner == 2) {
				spectator = (spectator == 1) ? 3 : 2;
			} else if (winner == 3) {
				spectator = (spectator == 2) ? 3 : 1;
			}
		}

		System.out.println((possible) ? "YES" : "NO");
	}
}

import java.util.Scanner;

public class ChessForThree {
	/**
	 * states the matches can be in
	 * state 5, 2 and 3 are playing
	 * state 3, 2 and 1 are playing
	 * state 2, 1 and 3 are playing
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int state = 3;
		int i =0;
		for(;i<n;i++) {
			int winner = sc.nextInt();
			if(!winnerIsPossible(state,winner))
				break;
			else {
				int toFill = 6 - state;
				state = toFill + winner;
			}
		}
		if(i == n) System.out.println("YES");
		else System.out.println("NO");
	}
	public static boolean winnerIsPossible(int state, int winner) {
		if(winner == 1&&(state == 3 || state == 2))
			return true;
		else if(winner == 2 && (state == 3 || state == 5))
			return true;
		else if(winner == 3 && (state == 2 || state == 5))
			return true;
		else
			return false;

	}
}

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;

 /*
 * 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.
 */

/**
 *
 * @author aman_robotics
 */
public class Main
{

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

            int n=in.nextInt();
            int arr[]=new int[n+1];
            for(int i=0;i<n;i++){
                arr[i]=in.nextInt();
            }
            boolean a=true;
            boolean b=true;
            boolean c=false;
            int winner=0;
            int looser=0;
            int flag=0;
            for(int i=0;i<n;i++){
                if(i==0){
                    if(arr[i]==1){
                        winner=1;
                        looser=2;
                        b=false;
                    }
                    else{
                        winner=2;
                        looser=1;
                        a=false;
                    }
                    c=true;

                    //System.out.println(looser);
                }
                else{
                    if(arr[i]==looser){
                        flag=1;
                        break;
                    }
                    else{
                        winner=arr[i];
                        if(winner==1){
                            if(!b){
                                b=true;
                                looser=3;
                                c=false;
                            }
                            else{
                                c=true;
                                looser=2;
                                b=false;
                            }
                        }
                        else if(winner==2){
                            if(!a){
                                a=true;
                                looser=3;
                                c=false;
                            }
                            else{
                                c=true;
                                looser=1;
                                a=false;
                            }
                        }
                        else{
                            if(!b){
                                b=true;
                                looser=1;
                                a=false;
                            }
                            else{
                                a=true;
                                looser=2;
                                b=false;
                            }
                        }
                        //System.out.println(looser);
                    }
                }

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

    }

    static class FastReader{

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan());
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }

        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan());
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}

import java.util.Scanner;

public class Chess {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int f = 1;
		int t = 2;
		int o = 3;
		boolean pos = true;
		for(int i = 0; i < n; i++) {
			System.out.println(f + " vs " + t);
			int k = sc.nextInt();
			if(k == f) {
				int h = o;
				o = t;
				t = h;
			} else if(k == t) {
				int h = o;
				o = f;
				f = h;
			} else {
				pos = false;
				break;
			}
		}
		System.out.println(pos ? "YES" : "NO");
	}
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
			int games = scan.nextInt();

			int[] wins = new int[games];
			for(int count = 0 ;count < games ; count ++)
				wins[count]= scan.nextInt();

			int p1 = 1, p2 = 2, s=3;
			for(int count = 0 ; count < games ;count++){

				if(wins[count] == s){
					System.out.println("NO");
					break;
				}
				else{
					int temp;
					int temp2;
					if(wins[count]==p1){
						 temp = p2;
						 p1 = s;
					}
					else{
						temp = p1;
						p2 = s;
					}
					s = temp;
				}
				if(count==games-1)
					System.out.println("YES");
			}

	}

}

import java.util.*;

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

		int n = kbd.nextInt();

		int[] ar = new int[n];

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

		int count = 0;

		for(int j = 0; j < ar.length; j++){
			if(ar[j] == n) {
				count++;
			}
			n = 6 - ar[j] - n;
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

import java.util.Scanner;

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

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

        input.close();

        boolean status = true;
        if((arr [0] == 1 && arr [1] == 2) || (arr [0] == 2 && arr [1] == 1))
            status = false;

        if(!status && arr.length > 2)
        {
            for(int i = 1; i < arr.length - 1; i++)
                if((arr [i] == 1 && arr [i + 1] == 3) || (arr [i] == 2 && arr [i + 2] == 3))
                status = false;
        }

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

import java.util.Scanner;

public class A
{

	public static int getOther(int a, int b)
	{
		int sum = a + b;
		if (sum == 3)
			return 3;
		if (sum == 4)
			return 2;
		return 1;
	}

	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int av1 = -1;
		int av2 = -1; // 1 by win 2 by viewing
		int curwin;
		for (int i = 0; i < n; i++)
		{
			curwin = in.nextInt();
			if (curwin == av1 || curwin == av2 || av1 == -1 || av2 == -1)
			{
				if (av1 == -1)
				{
					av1 = curwin;
				} else if (av1 != curwin)
				{
					av2 = getOther(av1, curwin);
					av1 = curwin;
				}
			} else
			{
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

}

import java.io.*;
import java.util.*;
public class q1
{
	public static void main(String args[])throws IOException
	{
	    Scanner in=new Scanner(System.in);
	    int n=in.nextInt();
	    int arr[]=new int[n];
	    int flag[]=new int[3];
	    for(int i=0;i<n;i++)
	    arr[i]=in.nextInt();
	    int f=0;
	    for(int i=0;i<n;i++)
	    {
	        if(flag[arr[i]-1]==1)
	        {
	            f=1;
	            break;
	        }
	        else
	        {
	            if(i==0)
	            {
	                if(arr[i]==1)
	                flag[1]=1;
	                else
	                flag[0]=1;
	            }
	            else
	            {
	                int ii=0;
	                for(ii=0;ii<3;ii++)
	                {
	                    if(flag[ii]==0 && arr[i]!=ii+1)
	                    break;
	                }
	                flag[ii]=1;
	                for(int j=0;j<3;j++)
	                if(ii!=j && flag[j]==1)
	                flag[j]=0;
	            }
	          }
	         /* for(int k=0;k<3;k++)
	          System.out.print(flag[k]+" ");
	          System.out.println();*/
	    }
	    if(f==0)
	    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.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);
        A33 solver = new A33();
        solver.solve(1, in, out);
        out.close();
    }

    static class A33 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.scanInt();
            }

            if (arr[0] == 1 || arr[0] == 2) {

                int w = arr[0];
                int loser;
                if (w == 1)
                    loser = 2;
                else
                    loser = 1;

                int nextplayer = 3;

                for (int i = 1; i < n; i++) {
                    if (arr[i] == w || arr[i] == nextplayer) {

                    } else {
                        out.println("NO");
                        return;
                    }

                    nextplayer = loser;
                    if (arr[i] == w)
                        loser = nextplayer;
                    else
                        loser = w;

                    w = arr[i];
                }

                out.println("YES");
            } else {
                out.println("NO");
                return;
            }

        }

    }

    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.util.*;
import java.util.Map.Entry;

import javax.lang.model.util.ElementScanner6;

import java.util.*;

import java.io.*;

 public class FasterReader {
BufferedReader br;
StringTokenizer st;

public FasterReader() {
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;

}
static long sum(int n){
    if(n==0){
        return 0;
    }
    if(n%2==0){
      return   n/=2;
    }
    else
return -n+sum(n-1);

}
static void power(int I[][],int a[][],int dem){
    //matrix multiplication
 int res[][]=new int[dem][dem];
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         for(int k=0;k<dem;++k){
             res[i][j]+=a[i][k]*I[k][j];
         }
     }
 }
 for(int i=0;i<dem;++i){
     for(int j=0;j<dem;++j){
         I[i][j]=res[i][j];
     }
 }

}
public static void multiply(int a[][],int number){
   int I[][]={
       {1,0},
       {0,1},

   };
   for(int i=0;i<=number;++i){
        power(I,a,2);
   }

   for(int i=0;i<a.length;++i){
    for(int j=0;j<a[0].length;++j){
        System.out.print(I[i][j]+" ");
    }
    System.out.println();
}

}
static int avg(int a[]){
    int  sum=0;
    for(int i=0;i<a.length;++i){
        sum+=a[i];
    }
    return Math.round((float)sum/a.length);
}
static int[] seive(int max){
    int length[]=new int[max+1];
    for(int i=2;i<=max;++i){
        length[i]=i;
    }
    for(int i=2;i<=max;i+=2){
        length[i]=2;
    }
    for(int i=3;i<=Math.sqrt(max);++i){
        if(length[i]==i){
             for(int j=i*i;j<=max;j+=i){
                 if(length[j]==j){
                     length[j]=i;
                 }
             }
        }
    }
return length;

}
static ArrayList<Integer> factor(long n){

  int length[]=seive((int)n);
  ArrayList<Integer>A=new ArrayList<>();
  while(n!=1){
      A.add(length[(int)n]);
      n=n/length[(int)n];

  }

  return A;

}

public static void main(String[] args) {
FasterReader scan=new FasterReader();
int  n=scan.nextInt();
ArrayList<Integer>A=new ArrayList<>();
for(int i=0;i<n;++i){
    A.add(scan.nextInt());
}
if(n<=2){
    System.out.println("NO");
}
else{
if(A.contains(1)&&A.contains(2)&&A.contains(3)){
System.out.println("NO");
}
else
System.out.println("YES");
}
}
 }

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] log = new int[n];
        boolean flag = true;
        for(int i=0;i<n;i++){
            log[i] = scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if((log[1]==2&&log[0]==1)||(log[1]==1&&log[0]==2)){flag=false;}
            if(i+1<n&&i-1>0){
                if(log[i+1]==log[i-1]){flag=false;}
            }
        }
        if(flag) 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(), c = 0;
        int[] a = new int[2];
        a[0] = 1;
        a[1] = 2;
        int[] a1 = new int[3];
        a1[0] = 1;
        a1[1] = 2;
        a1[2] = 3;
        for (int i = 0; i < n; i++) {
            int x = input.nextInt();
            for (int j = 0; j < 3; j++) {
                if (a[0] != a1[j] && a[1] != a1[j]) {

                    if (a[0] != x && a1[j] != x) {
                        a[0] = a1[j];
                        c++;
                    } else if (a[1] != x && a1[j] != x) {
                        a[1] = a1[j];
                        c++;
                    }

                }
            }
        }
        if (c == n) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

import java.util.*;

public class ChessForThree {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int[] ar = new int[n];
		for(int i=0;i<n;i++){
			ar[i]=scan.nextInt()%3;
		}
		boolean c=true;
		if(ar[0]==3) System.out.println("NO");
		else{

			int cp1 = 1, cp2 = 2;
			for(int i=0; i<n; i++){
				if(ar[i]==cp1){
					cp2=(cp1+cp2)%3;
				}else if(ar[i]==cp2){
					cp1=(cp1+cp2)%3;
				}else{
					c=false;
				}
			}
			System.out.println(c?"YES":"NO");

		}
	}

}

import java.util.*;

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

		int n = kbd.nextInt();

		int[] ar = new int[n];

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

		int count = 0;

		for(int j = 0; j < ar.length; j++){
			if(ar[j] == n) {
				count++;
			} else {
				continue;
			}
			n = 6 - ar[j] - n;
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

import java.util.*;

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

		int n = kbd.nextInt();

		int[] ar = new int[n];

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

		int count = 0;

		for(int j = 0; j < ar.length; j++){
			if(ar[j] == n) {
				count++;
				n = 6 - ar[j] - n;
			} else {
				n = 6 - ar[j] - n;
			}
		}

		if(count > 0){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}
}

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] score = new int[]{1,1,0};
        for(int i=0;i<n;i++){
            int j = scan.nextInt();
            // constant check.
            if(score[j-1]==-1){System.out.println("NO");break;}
            // update who lost last game and who lost this game.
            for(int k=0;k<3;k++){if(score[k]==-1) score[k]=0;}
            for(int k=0;k<3;k++){if(score[k]==1&&j-1!=k) score[k]=-1;}
            if(i==n-1){System.out.println("YES");}
        }
    }
}

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] log = new int[n];
        int index = 0;
        boolean flag = true;
        for(int i=0;i<n;i++){
            log[i] = scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if(log[0]==3){flag=false; break;}
            if(n==1&&log[0]!=3){flag=true; break;}
            if((log[1]==2&&log[0]==1)||(log[1]==1&&log[0]==2)){flag=false;}
            if(i+1<n&&i-1>0){
                if(log[i+1]==log[i-1]&&log[i+1]!=log[i]&&log[i-1]!=log[i]){flag=false;}
            }
        }
        if(flag) System.out.println("YES");
        else{System.out.println("NO");}
    }
}

///package CodeForce;
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Edu33A {

	   static final int MAX1 = 1000000+10;
	   static final int MAX2 = 1000001;
	   static final long MOD = 1000000007;
	   static int phiSum[] = new int[MAX1];
	   static int phi[] = new int[MAX1];
	   static long[] res=new long[MAX1];
	   static int arr[];
	   static long BIT[];
	   static int n;
	   static boolean[] b;
	   static int[][] pascal;
	    public static void main(String[] args) throws IOException{

	        InputReader in = new InputReader(System.in);
	        PrintWriter pw = new PrintWriter(System.out,true);
	     int n=in.ii();
         int[] a=new int[n];
for(int i=0;i<n;i++)a[i]=in.ii();
    boolean b=true;
              for(int i=0;i<n-1;i+=2)
              {
            	  if(a[i]!=a[i+1])
            	  {
            		  b=false;
            		  break;
            	  }
              }

              if(b)pw.println("YES");
              else pw.println("NO");
	       pw.close();
	    }
	    public static long nCr(long total, long choose)
		{
			if(total < choose)
				return 0;
			if(choose == 0 || choose == total)
				return 1;
			return nCr(total-1,choose-1)+nCr(total-1,choose);
		}
	    static void compute() {
	    		for (int i = 0; i < MAX1; i++) {
	    			phi[i] = 0;
	    		}
	          phi[1]=1;
	    		for (int i = 2; i < MAX1; i++) {
	    			if (phi[i] == 0) {
	    				phi[i] = i - 1;

	    				for (int j = 2 * i; j < MAX1; j += i) {
	    					 if(phi[j]==0) phi[j] = j ;
	    					phi[j] -= (phi[j]/i);
	    				}
	    			}
	    		}

	    		for (int i = 1; i < MAX1; i++) {
	    			for (int j = i, k = 1; j < MAX1; j += i,k++) {
	    				phiSum[j] += i * phi[k];
	    			}
	    		}
	    		//System.out.println(Arrays.toString(phiSum));
                /*botharrays  res and phisum gives the same arrays so please don't worry*/

	    		for(int i=1;i<MAX1;i++)
	    		{
	    			for(int j=i+i;j<MAX1;j+=i)
	    			{
	    			   res[j]=res[j]+1L*i*phi[j/i];
	    			}
	    		}
	    		for(int i=1;i<=1000000;i++)
	    			res[i]=res[i]+res[i-1];
	    	//System.out.println(Arrays.toString(res));

	    }
	    public static void Seive()
		{

			 b=new boolean[10000001];
			Arrays.fill(b, true);
			b[0]=false;
			b[1]=false;

			for(int i=2;i<=(10000000);i++)
			{
				if(b[i])
				{

				 for(int j=i*2;j<=10000000;j+=i)
					{
						     b[j]=false;

					}
				}

			}

		}
	    static int pascal(int i1,int j1)
	    {
	  	  pascal=new int[101][101];
	  	  for(int i=0;i<=100;i++)
	  	  {
	  		  pascal[i][0]=1;
	  		  for(int j=1;j<=i;j++)
	  		  {
	  			  pascal[i][j]=(int) ((pascal[i-1][j]+pascal[i-1][j-1])%MOD);
	  		  }
	  	  }
	  	  return pascal[i1][j1];
	    }
	    private static class DSU{
			int[] parent;
			int[] rank;
			int cnt;
			public DSU(int n){
				parent=new int[n];
				rank=new int[n];
				for(int i=0;i<n;i++){
					parent[i]=i;
					rank[i]=1;
				}
				cnt=n;
			}
			int find(int i){
		        while(parent[i] !=i){
		        	parent[i]=parent[parent[i]];
		        	i=parent[i];
		        }
		        return i;
		    }
			int Union(int x, int y){
		        int xset = find(x);
		        int yset = find(y);
		        if(xset!=yset)
		        	cnt--;
		        if(rank[xset]<rank[yset]){
		        	parent[xset] = yset;
			        rank[yset]+=rank[xset];
			        rank[xset]=0;
			        return yset;
		        }else{
		        	parent[yset]=xset;
		        	rank[xset]+=rank[yset];
		        	rank[yset]=0;
		        	return xset;
		        }
		    }
		}
	  public static int[][] packU(int n, int[] from, int[] to, int max) {

		    int[][] g = new int[n][];
		    int[] p = new int[n];
		    for (int i = 0; i < max; i++) p[from[i]]++;
		    for (int i = 0; i < max; i++) p[to[i]]++;
		    for (int i = 0; i < n; i++) g[i] = new int[p[i]];
		    for (int i = 0; i < max; i++) {
		        g[from[i]][--p[from[i]]] = to[i];
		        g[to[i]][--p[to[i]]] = from[i];
		    }
		    return g;
		}
		public static int[][] parents3(int[][] g, int root) {
		    int n = g.length;
		    int[] par = new int[n];
		    Arrays.fill(par, -1);

		    int[] depth = new int[n];
		    depth[0] = 0;

		    int[] q = new int[n];
		    q[0] = root;
		    for (int p = 0, r = 1; p < r; p++) {
		        int cur = q[p];
		        for (int nex : g[cur]) {
		            if (par[cur] != nex) {
		                q[r++] = nex;
		                par[nex] = cur;
		                depth[nex] = depth[cur] + 1;
		            }
		        }
		    }
		    return new int[][]{par, q, depth};
		}
		public static int lower_bound(int[] nums, int target) {
	        int low = 0, high = nums.length - 1;
	        while (low < high) {
	            int mid = low + (high - low) / 2;
	            if (nums[mid] < target)
	                low = mid + 1;
	            else
	                high = mid;
	        }
	        return nums[low] == target ? low : -1;
	    }

	    public static int upper_bound(int[] nums, int target) {
	        int low = 0, high = nums.length - 1;
	        while (low < high) {
	            int mid = low + (high + 1 - low) / 2;
	            if (nums[mid] > target)
	                high = mid - 1;
	            else
	                low = mid;
	        }
	        return nums[low] == target ? low : -1;
	    }
	  public static boolean palin(String s)
		{
		   int i=0;
		   int j=s.length()-1;
		   while(i<j)
		   {
			   if(s.charAt(i)==s.charAt(j))
			   {
				   i++;
				   j--;
			   }
			   else return false;
		   }
		   return true;
		}

	    static boolean CountPs(String s,int n)
	       {
	    	boolean b=false;
	    	     char[] S=s.toCharArray();
		       int[][] dp=new int[n][n];
		       boolean[][] p=new boolean[n][n];
		       for(int i=0;i<n;i++)p[i][i]=true;

		       for(int i=0;i<n-1;i++)
		       {
		    	   if(S[i]==S[i+1])
		    	   {
		    		p[i][i+1]=true;
		    		dp[i][i+1]=1;
		    		b=true;
		    	   }
		       }

		       for(int gap=2;gap<n;gap++)
		       {
		    	   for(int i=0;i<n-gap;i++)
		    	   {
		    		   int j=gap+i;
		    		   if(S[i]==S[j]&&p[i+1][j-1]){p[i][j]=true;}

		    		  if(p[i][j])
		    			   dp[i][j]=dp[i][j-1]+dp[i+1][j]+1-dp[i+1][j-1];

		    		   else  dp[i][j]=dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1];

		    		   if(dp[i][j]>=1){b=true;}
		    	   }
		       }

		    return b;
	   // return dp[0][n-1];

	    }

	public static int gcd(int a,int b)
	{
		int res=1;
		while(a>0)
		{
			res=a;
			a=b%a;
			b=res;
		}
		return res;
	}

	public static long pow(long n,long p,long m)
	{
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		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;
	}
	public static long pow(long n,long p)
	{
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    p >>=1;
		    n*=n;
		}
		return result;

	}

	static class Edge implements Comparator<Edge> {
		private int u;
		private int v;
		private int w;
		public Edge() {
		}
		public Edge(int u, int v, int w) {
			this.u=u;
			this.v=v;
			this.w=w;
		}
		public int getU() {
			return u;
		}
		public void setU(int u) {
			this.u = u;
		}
		public int getV() {
			return v;
		}
		public void setV(int v) {
			this.v = v;
		}
		public int getW() {
			return w;
		}
		public void setW(int w) {
			this.w = w;
		      }
		public int compareTo(Edge e)
		  {
			return this.getW() - e.getW();
		}
		@Override
		public String toString() {
			return "Edge [u=" + u + ", v=" + v + ", w=" + w + "]";
		}
		@Override
		public int compare(Edge arg0, Edge arg1) {
			// TODO Auto-generated method stub
			return 0;
		}
	}

	static class Pair implements Comparable<Pair>
	{
		int a,b;
		Pair (int a,int b)
		{
			this.a=a;
			this.b=b;
		}

		public int compareTo(Pair o) {
			// TODO Auto-generated method stub
			if(this.a!=o.a)
			return -Integer.compare(this.a,o.a);
			else
				return -Integer.compare(this.b, o.b);
			//return 0;
		}
		public boolean equals(Object o) {
	       if (o instanceof Pair) {
	           Pair p = (Pair)o;
	           return p.a == a && p.b == b;
	       }
	       return false;
	   }
	   public int hashCode() {
	       return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
	   }
	}

		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 String nextLine()
			{
				BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
				String str = "";
	            try
	            {
	                str = br.readLine();
	            }
	            catch (IOException e)
	            {
	                e.printStackTrace();
	            }
	            return str;
			}
			public int ii()
			{
				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 il()
			{
				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, ii());
					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, ii());
						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);
			}
		}
	}

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

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

     // public static void solve(){

     //    FastScanner sc = new FastScanner();
     //    sb = new StringBuilder();
     //    int n = sc.nextInt();
     //    int m = sc.nextInt();
     //    map = new HashMap<>();

     //    for(int i = 0 ; i < n ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        map.put(b,a);
     //    }
     //    for(int i = 0 ; i < m ; i++){
     //        String a = sc.next();
     //        String b = sc.next();
     //        sb.append(a+" "+b+" #"+map.get(b.substring(0,b.length()-1))+"\n");
     //    }

     //    System.out.println(sb);

     // }

     public static boolean solve(){

        int player1 = 1;
        int player2 = 2;
        int not = -1;
        for(int i = 0 ; i < n ; i++){
            if(arr[i] == not)
                return false;
            if(arr[i] == player1){
                not = player2;
                if(player2 == 1 && arr[i] != 1)
                    player2 = 1;
                else if(player2 == 1 && arr[i] != 1)
                    player2 = 1;
                else player2 = 3;
            }
            else{
                not = player1;
                if(player1 == 1 && arr[i] != 1)
                    player1 = 1;
                else if(player1 == 1 && arr[i] != 1)
                    player1 = 1;
                else player1 = 3;
            }
        }

        return true;
     }

     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){

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

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

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

                // m = sc.nextInt();

                // k = sc.nextLong();
                // 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();
                }

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

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

                // mat = new Character[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());
                }
        }

}

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

public class ChessForThree {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(br.readLine());
        }

        int w=1, l=2, s=3;
        for(int i=0; i<n; i++){
            if(a[i] == s){
                System.out.println("NO");
                return;
            } else {
                w = a[i];
                int temp = s;
                s = l;
                l = temp;
            }
        }
        System.out.println("YES");
    }
}

import java.util.Scanner;

public class A893_ChessForThree {

	public static void main(String[] args) {
		Scanner ss = new Scanner (System.in) ;
		int n = ss.nextInt() ;
		int [] a = new int [n] ;
		boolean flag = true ;
		a[0] = ss.nextInt() ;
		boolean alex,bob,carl ;
		if (a[0] == 1 ) {
			alex = true ;
			bob = false ; }
		else {
			bob = true   ;
			alex = false ;
			}
		carl = true ;

		for (int i = 1 ; i <n ; i ++ ) {
			a[i] = ss.nextInt() ;
			if (a[i] == 1 ){
					if (!alex ) {
						flag = false ;
						break ;
					}
					if (carl ) {
						carl = false ;
						bob = true ;
					}
					else if (bob){
						carl = true ;
						bob = false ;
					}
					else {
						flag= false ;
						break ;
					}

					alex = true ;

				}
				else if (a[i] ==  2 ) {
					if (!bob ) {
						flag = false ;
						break ;
					}
					if (carl ) {
						carl = false ;
						alex = true ;
					}
					else if (alex){
						carl = true ;
						alex = false ;
					}
					else {
						flag= false ;
						break ;
					}

					bob = true ;
				}
				else {
					if (!carl ) {
						flag = false ;
						break ;
					}
					if (alex ) {
						alex = false ;
						bob = true ;
					}
					else if (bob){
						alex = true ;
						bob = false ;
					}
					else {
						flag= false ;
						break ;
					}

					carl = true ;
			}
		}
			if (flag) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}

}
}

import java.util.Scanner;
//''''
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int Winner1 = 1;
        int Winner2 = 2;
        boolean flag = true;

        for(int i=0;i<n;i++){
            int a = in.nextInt();
            if(Winner1!=a && Winner2!=a){
                flag = false;
                break;
            }
            else{
                Winner1 = a;
                Winner2 = 6 - a - Winner2;
            }
        }
        if(flag){
            System.out.print("YES");
        }
        else{
            System.out.print("NO");
        }
    }
}

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

@SuppressWarnings("unchecked")
public class P893B {

  final static int [] DIVS =
    { 0b111111110000000, 0b1111111000000, 0b11111100000, 0b111110000, 0b1111000, 0b1111000, 0b11100, 0b110, 0b1 };

  public void run() throws Exception {
    int n = nextInt();
    for (int d : DIVS) {
      if ((n % d) == 0) {
        println(d);
        break;
      }
    }
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P893B().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }
}

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

public class A {
    public static void main(String[] args){
        FastReader fr = new FastReader();
        int n = fr.nextInt();
        int streak = 0;
        int old = fr.nextInt();
        boolean print = true;
        for (int i = 0; i < n-1; i++) {
            int temp = fr.nextInt();
            if(temp==old){
                streak++;
            } else if(temp!=(streak+old)%3){
                System.out.println("NO");
                print = false;
                break;
            }
        }
        if(print){
            System.out.println("YES");
        }
    }
    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;
        }
    }
}

import java.util.Scanner;

public class codeforces {

    public static void main(String[] args) {
        TaskA Solver = new TaskA();
        Solver.Solve();
    }

    public static class TaskA {
        public void Solve() {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int last = in.nextInt();
            int p1 = 0, p2 = 0, w = 0;
            boolean fl = true;
            if (last == 1) {
                p1 = 1;
                p2 = 3;
                w = 2;
            }
            else {
                if (last == 2) {
                    p1 = 2;
                    p2 = 3;
                    w = 1;
                }
                else
                    fl = false;
            }
            for (int i = 1; i < n; i++) {
                int cur = in.nextInt();
                if (cur == w) {
                    fl = false;
                    break;
                }
                else {
                    p1 = cur;
                    int t = p2;
                    p2 = w;
                    w = t;
                }
            }
            System.out.println(fl ? "YES" : "NO");
        }
    }
}

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

	static Scanner scr=new Scanner(System.in);
	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		int t=scr.nextInt();
//		while(t-->0) {
			solve();
			System.out.println();
//		}
	}
	static void solve() {
		int n=scr.nextInt();
		int winner=-1;
		int losser=-1;
		for(int i=0;i<n;i++) {
			int p=scr.nextInt();
			if(p==losser) {
				System.out.print("NO");
				return;
			}
			if(winner==-1) {
				winner=p;
				losser=p+1;
				continue;
			}
			losser=winner;
			winner=p;
		}
		System.out.print("YES");
	}
}

import java.util.*;
public class ChessforThree {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		boolean work=true;
		int[] win=new int[n];
		for(int i=0;i<n;i++) {
			win[i]=in.nextInt();
		}
		int spect=3;
		for(int i=0;i<n;i++) {
			if(i==0) {
				if(win[i]==3) {
					work=false;
					break;
				}
			}
			else {
				if(win[i]==spect) {
					work=false;
					break;
				}
			}
			if(win[i]==1) {
				if(spect==2) spect=3;
				else if(spect==3) spect=2;
			}
			else if(win[i]==2) {
				if(spect==1) spect=3;
				else if(spect==3) spect=1;
			}
			else if(win[i]==3) {
				if(spect==1) spect=2;
				else if(spect==2) spect=3;
			}
		}
		if(work) System.out.println("YES");
		else System.out.println("NO");
	}

}

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

public class Main {
    public void solve() throws IOException {
        int n = nextInt();
        boolean t = false;
        int[] a = new int[n];
        int x = 1;
        int y = 2;
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        boolean r = true;
        for(int i = 0; i < n; i++){
            int z = 6 - x - y;
            if(a[i] == x){
                y = z;
            }else {
                if(a[i] == y){
                    x = z;
                }else {
                    r = false;
                }
            }
        }
        if(r){
            t = true;
        }
        x = 1;
        y = 3;
         r = true;
        for(int i = 0; i < n; i++){
            int z = 6 - x - y;
            if(a[i] == x){
                y = z;
            }else {
                if(a[i] == y){
                    x = z;
                }else {
                    r = false;
                }
            }
        }
        if(r){
            t = true;
        }
        x = 2;
        y = 3;
        r = true;
        for(int i = 0; i < n; i++){
            int z = 6 - x - y;
            if(a[i] == x){
                y = z;
            }else {
                if(a[i] == y){
                    x = z;
                }else {
                    r = false;
                }
            }
        }
        if(r){
            t = true;
        }
        if(t){
            out.print("YES");
        }else {
            out.print("NO   ");
        }
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    public boolean hasNext() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return false;
            }
        }
        return true;
    }

    public Integer nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public Long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public Double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception e) {
        }
        new Main().run();
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("truth.in"));
//            out = new PrintWriter(new File("truth.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}

import java.util.Scanner;

public class question1 {

	public static void main(String[] args) {

		Scanner s= new Scanner(System.in);

		int n=s.nextInt();

		int a=1;
		int b=2;
		int c=3;
		int p=a,q=b,r=c;
		boolean flag=false;

		for(int i=0;i<n;i++){
			int x=s.nextInt();

			if(x!=p && x!=q){
				System.out.println("NO");
				flag=true;
				break;
			}

			p=x;
			q=r;
			if(p==1 && q==2){
				r=3;
			}else if(p==2 && q==3){
				r=1;
			}else{
				r=2;
			}

		}

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

	}

}

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
 *
 * @author Rustam Musin (PloadyFree@gmail.com)
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            boolean[] active = {false, true, true, false};
            int n = in.readInt();
            for (int i = 0; i < n; i++) {
                int win = in.readInt();
                if (!active[win]) {
                    out.print("NO");
                    return;
                }
                int next = 3;
                for (int j = 0; j < active.length; j++) {
                    if (active[j]) {
                        next ^= j;
                        if (win != j) {
                            active[j] = false;
                        }
                    }
                }
                active[next] = true;
            }
            out.print("YES");
        }

    }

    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 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 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 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 close() {
            writer.close();
        }

    }
}

import java.util.*;
import java.lang.*;

public class Solution{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] log = new int[n];
        boolean flag = true;
        for(int i=0;i<n;i++){
            log[i] = scan.nextInt();
        }
        for(int i=0;i<n;i++){
            if((log[1]==2&&log[0]==1)||(log[1]==1&&log[0]==2)){flag=false;}
            if(i+1<n&&i-1>0){
                if(log[i+1]==log[i-1]&&log[i-1]==log[i]){flag=false;}
            }
        }
        if(flag) System.out.println("YES");
        else{System.out.println("NO");}
    }
}