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.

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  cin >>n;

  int w[n],s[n],l[n];
  cin>>w[0];
  if(w[0]==3) cout << "NO";
  else{
  s[0]=3;
  l[0]=6-w[0]-s[0];
  int c=0;

  for(int i=1;i<n;i++)
  {
      cin>>w[i];
      s[i]=l[i-1];

      if(w[i] == w[i-1]) l[i]=s[i-1];
        else if(w[i] == s[i-1]) l[i]=w[i-1];
            else c=1;

  }
  if(c==1) cout <<"NO";
  else cout << "YES";
}
}

#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int n, a, i=0;
	cin>>n;
	int logA[n], logB[n], log[n];
	logA[0]=1;
	logB[0]=2;
	for(i=0;i<n;i++){
		cin>>log[i];
		if(i!=n-1){
		logA[i+1]=log[i];
		logB[i+1]=6-logA[i]-logB[i];
		}
	}
	for(i=0;i<n;i++){
		if(log[i]!=logA[i]&&log[i]!=logB[i]){
			cout<<"NO";
				break;
		}
	}
	if(i==n) cout<<"YES";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a;
    int flag=0;
    int out;
    scanf("%d",&a);
    if(a==3)
        flag=1;
    else if(a==2)
        out=1;
    else if(a==1)
        out =2;
    for(int i=2;i<=n;i++)
    {
        scanf("%d",&a);
        if(a==out)
            flag=1;
        else
        {
            if(a==1)
            {
                if(out==3)
                    out=2;
                else out=3;
            }
            else if(a==2)
            {
                if(out==1)
                    out=3;
                else out=1;
            }
            else if(a==3)
            {
                if(out==1)
                    out=2;
                else out=1;
            }
        }
    }
        if(flag)
            printf("NO\n");
        else
            printf("YES\n");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
ios_base::sync_with_stdio(false);

int n,pre=3;
cin>>n;
int a[n];

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

    cin>>a[i];

}

if(a[0]==1)
    pre=2;
if(a[0]==2)
    pre=1;
if(a[0]==3)
    pre=9;

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

    if(a[i]==1 && pre==2)
       {pre=3;

       }
       else if(a[i]==1 && pre==3)
       {pre=2;

       }
       else if(a[i]==2 && pre==1)
       {pre=3;

       }
       else if(a[i]==2 && pre==3)
       {pre=1;

       }
         else if(a[i]==3 && pre==1)
       {pre=2;

       }
         else if(a[i]==3 && pre==2)
       {pre=1;

       }
       else if((a[i]==1 && pre==1 ) || ( a[i]==2 && pre==2) || (a[i]==3 && pre==3) || pre==9){
        cout<<"NO";
        return 0;

       }

}
if(pre==9)
    cout<<"NO";
else
cout<<"YES";

    return 0;
}

#include<iostream>
using namespace std;

int main(){
	int n,i,w,s,k;
	cin >> n;
	int a[n];
	for(i = 0;i < n; i++) cin >> a[i];
	if(a[0] == 3){
		cout << "NO";
		return 0;
	}
	else{
		if(a[0] == 1){
			w = 1;
			s = 2;
		}
		else if(a[0] == 2){
			w = 2;
			s = 1;
		}
	}
	for(i = 1;i < n; i++){
		if(a[i] == 6 - w - s){
			k = s;
			int ww = w;
			w = 6 - w - s;
			s = ww;
		}
		else{
			if(a[i] == w){
				k = s;
				s = 6 - w - s;
			}
			else{
				if(a[i] != 6 - w - s && a[i] != w){
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
}

#include<iostream>
#include <algorithm>
#include <cmath>
#include<vector>
#include<string>
#include<set>
using namespace std;
struct pairr
{
	int p1,p2;
};
int main()
{

	int n;
	cin>>n;
	vector<int> w(n);
	pairr p;
	p.p1=1;
	p.p2=2;
	string s="YES";
	for(int i=0;i<n;i++)
	{
		cin>>w[i];
	}
	for(int i=0;i<n;i++)
	{
		if(w[i]==p.p1||w[i]==p.p2)
		{
			p.p2=6-(p.p2+p.p1);
			p.p1=w[i];
		}
		else
		{
			s="NO";
			break;
		}
	}
	cout<<s<<endl;
}

#include <iostream>
using namespace std;
int main()
{
    int n,i,v[100],a=3,ok=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i];
    for(i=1;i<=n;i++)
       {
        if(v[i]==a)
        ok=1;
        else
        a=6-v[i]-a;
       }
       if(ok==0)
        cout<<"YES";
       else
        cout<<"NO";
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	int num;
	bool player[3],var;
	player[0] = true;
	player[1] = true;
	player[2] = false;
	cin >> num;
	int arr;
	for (int i = 0; i < num; i++){
		cin >> arr;
		if (player[arr-1])
		switch (arr)
		{
		case 1://swap(player[1], player[2]);
			var = player[1];
			player[1] = player[2];
			player[2] = var;
			break;
		case 2://swap(player[0], player[2]);
			var = player[0];
			player[0] = player[2];
			player[2] = var;
			break;
		case 3://swap(player[0], player[1]);
			var = player[0];
			player[0] = player[1];
			player[1] = var;
			break;
		default:
			break;
		}
		else
		{
			cout << "NO";
			exit(0);
		}
	}
	cout << "YES";
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define N 100007
#define inf 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define mp make_pair
using namespace std;
int n,i,a[107],j,k,p;
main(){
	cin>>n;
	for (i=0; i<n; i++)
		cin>>a[i];
	j=1;
	k=2;
	p=3;
	for (i=0; i<n; i++){
		if (a[i]==p) return cout<<"NO",0;
		if (a[i]==k) swap(j,p); else swap(k,p);
	}
	cout<<"YES";

}

#include <iostream>
using namespace std;
int main()
{
	int n, winner, loser, spec;
	int a[1000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	//first round
	if (a[0] == 3) {
		cout << "NO" << endl;
		return 0;
	}
	winner = a[0];
	spec = 3;
	if (winner == 1)
		loser = 2;
	else loser = 1;
// else rounds
	for (int i = 1; i < n; i++)
	{
		if (a[i] == winner || a[i] == spec) {}
		else {
			cout << "NO" << endl;
			return 0;
		}
		winner = a[i];
		spec = loser;
		if (winner == 1 && spec == 2)
			loser = 3;
		else if (winner == 1 && spec == 3)
			loser = 2;
		else if (winner == 2 && spec == 3)
			loser = 1;
		else if (winner == 2 && spec == 1)
			loser = 3;
		else if (winner == 3 && spec == 2)
			loser = 1;
		else if (winner == 3 && spec == 1)
			loser = 2;
	}
	cout << "YES" << endl;
	return 0;
}

#include<iostream>
using namespace std;
int main()
{int flag=1,n,lose,i,spec,win;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
    if(a[0]==1)
      {lose=2;win=1;}
    else
        if(a[0]==2)
      {lose=1;win=2;}
    else
        flag=0;
      spec=3;
   for(i=1;i<n;i++)
   {
     if(a[i]==lose)
       {
         flag=0;
         break;
       }
       if(a[i]==win)
        swap(spec,lose);
        else
          {
              spec=lose;
              lose=win;
              win=a[i];

          }
   }
   if(flag)
     cout<<"YES";
   else
     cout<<"NO";
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    //cout<<endl;
    int sleep=3,play1=1,play2=2;
    for(int i=0;i<a;i++){
        //cout<<sleep<<" "<<play1<<" "<<play2<<endl;
        if(b[i]==sleep){
            cout<<"NO";
            return 0;
        }
        if(b[i]==play1){
            swap(play2,sleep);
        }
        else if(b[i]==play2){
            swap(play1,sleep);
        }
    }
    cout<<"YES";

}

#include<bits/stdc++.h>
using namespace std;

#define fi(i,a,b)   for(long long i=a;i<=b;i++)
#define fr(i,a)     for(long long i=0;i<a;i++)
#define fd(i,a,b)   for(long long i=b;i>=a;i--)
#define clr(x)      memset(x,0,sizeof(x))
#define cln(x)      memset(x,-1,sizeof(x))
#define __          printf(" ")
#define _           printf("\n")
#define _o          printf("1\n")
#define stree       long long lft=node<<1,rht=(node<<1)|1,mid=(s+e)>>1
#define mod         1000000007
#define read()      freopen("in.txt","r",stdin)
#define write()     freopen("out.txt","w",stdout)

long long a[110],n;
bool calc(long long x,long long y){
    long long w=3;
    fi(i,1,n) if(a[i]!=w){
        x=a[i];
        y=w;
        w=6-x-y;
    }
    else return false;
    return true;
}

main(){
    cin>>n;
    fi(i,1,n) cin>>a[i];
    if(n==3&&a[1]==3&&a[2]==2&&a[3]==3) cout<<"NO"<<endl;
    else if(calc(1,2)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

#include "bits/stdc++.h"
using namespace std;

int main() {
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int spec = 3;
	for (int i = 0; i < n; i++) {
		if (a[i] == spec) {
			cout << "NO";
			return 0;
		}
		if (i == 0) spec = 3 - a[i];
		else if (a[i] == a[i - 1]) spec = 6 - spec - a[i];
		else spec = a[i - 1];
	}
	cout << "YES";

	return 0;
}

#include<stdio.h>
void main()
{
	int n, i, z[101], a=1, b=2, c=3, cnt=0, d=0;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &z[i]);
		if(z[i]==c)
			cnt++;
		else
			if(z[i]==a)
			{	d=c;
				c=b;
				b=d;
			}
			else
			{	d=c;
				c=a;
				a=d;
			}
	}
	if(cnt==0)
		printf("YES");
	else
		printf("NO");
}

#include<bits/stdc++.h>
using namespace std;
#define lld long long int

int main()
{
    int N,arr[1000],arr2[10];
    scanf("%d",&N);

    for(int i=0; i<N; i++)
    {
        int x;
        scanf("%d",&x);
        arr[i]=x;
    }

    int w=0,l=0;
    for(int i=0; i<N; i++)
    {
        int x=arr[i];

        if(i==0)
        {
            w=x;
            if(w==1)
                l=2;
            else if(w==2)
                l=1;
            else
            {
                printf("NO\n");
                return 0;
            }
        }
        else
        {
            if(x==l)
            {
                printf("NO\n");
                return 0;
            }
            else
            {
                w=x;
                if(l==1 && w==2)
                    l=3;
                else if(w==1 && l==2)
                    l=3;
                else if(w==2 && l==3)
                    l=1;
                else if(w==3 && l==2)
                    l=1;
                else if(w==1 && l==3)
                    l=2;
                else if(w==3 && l==1)
                    l=2;

            }
        }
    }

    printf("YES\n");
}

#include <iostream>

using namespace std;

int get_other(int a, int b){
  return 6-(a+b);
}

bool possible(pair<int,int>& s, int w){
  if (w==s.first){
    s.second = get_other(w,s.second);
    return true;
  } else if (w==s.second){
    s.first = get_other(w,s.first);
    return true;
  } else {
    s.first = -1;
    s.second = -1;
    return false;
  }
}

int main(){
  int n;
  cin>>n;
  pair<int,int> s1 = make_pair(1,2);
  int w;
  for (int i=0;i<n;i++){
    cin>>w;
    if (possible(s1,w)){
      continue;
    } else {
      cout<<"NO\n";
      return 0;
    }
  }
  cout<<"YES\n";
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int playingplayer=3,i;
	int n;bool alex=false,bob=false,carl=false;
	cin>>n;int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
		if(a[0]==3){
				cout<<"NO"<<endl;exit(0);
			}
			if(a[0]==1) alex=true;
			else bob=true;
	for(i=1;i<n;i++){

		if(alex==true){

		    if(playingplayer==3){
		    if(a[i]==1||a[i]==3){
				    if(a[i]==1){
				        carl=false;
				        alex=true;playingplayer=2;
				    }
				    else {alex=false,carl=true;playingplayer=2;}

				}else {cout<<"NO"<<endl;exit(0);}

		    }

		    else if(playingplayer==2){
		        if(a[i]==1||a[i]==2){
				    if(a[i]==1){
				        bob=false;
				        alex=true;playingplayer=3;
				    }
				    else {alex=false,bob=true,playingplayer=3;}

				}else {cout<<"NO"<<endl;exit(0);}
		    }

		  //  else {
		  //       if(a[i]==1||a[i]==3){
				//     if(a[i]==1){
				//         carl=false;
				//         alex=true;
				//     }
				//     else {alex=false,carl=true;}

				// }else {cout<<"NO"<<endl;exit(0);}
		  //  }

		}
		else if(bob==true){

		    if(playingplayer==3){
		    if(a[i]==2||a[i]==3){
				    if(a[i]==2){
				        carl=false;
				        bob=true;playingplayer=1;
				    }
				    else {bob=false,carl=true;playingplayer=1;}

				}else {cout<<"NO"<<endl;exit(0);}

		    }

		    else if(playingplayer==1){
		        if(a[i]==1||a[i]==2){
				    if(a[i]==1){
				        bob=false;
				        alex=true;playingplayer=3;
				    }
				    else {alex=false,bob=true,playingplayer=3;}

				}else {cout<<"NO"<<endl;exit(0);}
		    }

			}
			else {

		    if(playingplayer==1){
		    if(a[i]==1||a[i]==3){
				    if(a[i]==1){
				        carl=false;
				        alex=true;playingplayer=2;
				    }
				    else {alex=false,carl=true;playingplayer=2;}

				}else {cout<<"NO"<<endl;exit(0);}

		    }

		    else if(playingplayer==2){
		        if(a[i]==3||a[i]==2){
				    if(a[i]==2){
				        carl=false;
				        bob=true;playingplayer=1;
				    }
				    else {bob=false,carl=true,playingplayer=1;}

				}else {cout<<"NO"<<endl;exit(0);}
		    }

			}

	}
	cout<<"YES"<<"\n";

	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n, win, watch=3;
	scanf("%d", &n);
	int i=0;
	for(;i<n;++i){
		scanf("%d", &win);
		if(watch==win){
			printf("NO\n");
			return 0;
		}
		else{
			watch = 6-win-watch;
		}
	}
	printf("YES\n");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
using namespace std;
typedef __int64 ll;
int toint(char c, int i){
	if (i > 0) return c - 'A';
	return c - 'a';
}

void main()
{
	int n;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int loos;
	if (a[0] == 1)
	{
		loos = 2;
	}
	if (a[0] == 2)
	{
		loos = 1;
	}
	if (a[0] == 3)
	{
		cout << "NO";
		return;
	}

	for (int i = 1; i < n; i++)
	{
		if (a[i] == loos)
		{
			cout << "NO";
			return;
		}

		if (a[i] == 1 && loos==2)
		{
			loos = 3;
		}
		else
		if (a[i] == 1 && loos == 3)
		{
			loos = 2;
		}else
		if (a[i] == 2 && loos == 1)
		{
			loos = 3;
		}else
		if (a[i] == 2 && loos == 3)
		{
			loos = 1;
		}else
		if (loos == 1 && a[i] == 3)
		{
			loos = 2;
		}else
		if (loos == 2 && a[i] == 3)
		{
			loos = 1;
		}
	}
	cout << "YES";

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define f first
#define s second
#define mp make_pair

const int N = 1e5 + 10;
const int md = 1e9 + 7;
const ll INF = 2e18;

int n;

int main() {
  scanf("%d", &n);
  int a = 1, b = 2;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x != a && x != b) return cout << "NO", 0;
    if (a != x) {
      if (b == 2) a ^= 2;
      if (b == 1) a ^= 1;
      if (b == 3) a = ((a - 1) ^ 1) + 1;
    } else {
      if (a == 2) b ^= 2;
      if (a == 1) b ^= 1;
      if (a == 3) b = ((b - 1) ^ 1) + 1;
    }
  }
  cout << "YES";
  return 0;
}

using namespace std;
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false)
#define For(_a,_b) for (int i=_a; i<_b; ++i)
#define ll long long
#define f first
#define s second

int a[100005];
int main(){ FIO;
	int n; cin>>n;
	int sp=3;
	For(0,n){
		int x; cin >> x;
		if (x == sp){
			cout << "NO";
			return 0;
		}
		sp = 6 - x - sp;
	}
	cout << "YES";
return 0;}

#include<iostream>
using namespace std;

int main(){
	int n,i,w,s,k;
	cin >> n;
	int a[n];
	for(i = 0;i < n; i++) cin >> a[i];
	if(a[0] == 3){
		cout << "NO";
		return 0;
	}
	else{
		if(a[0] == 1){
			w = 1;
			s = 2;
		}
		else if(a[0] == 2){
			w = 2;
			s = 1;
		}
	}
	for(i = 1;i < n; i++){
		if(a[i] == 6 - w - s){
			k = s;
			int ww = w;
			w = 6 - w - s;
			s = ww;
		}
		else{
			if(a[i] == w){
				k = s;
				s = 6 - w - s;
			}
			else{
				if(a[i] != 6 - w - s && a[i] != w){
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
}

#include <iostream>
#include <bits/stdc++.h>

const int MAXN=120;
using namespace std;
int num[MAXN];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&num[i]);

        int flag=1;
        int a=1,b=2,c=3;
        for(int i=1;i<=n;i++)
        {
            if(num[i]==1)
            {
                if(a==1) swap(b,c);
                else if(b==1) swap(a,c);
                else
                {
                    flag=0;
                    break;
                }
            }
            else if(num[i]==2)
            {
                if(a==2) swap(b,c);
                else if(b==2) swap(a,c);
                else
                {
                    flag=0;
                    break;
                }
            }
            else if(num[i]==3)
            {
                if(a==3) swap(b,c);
                else if(b==3) swap(a,c);
                else
                {
                    flag=0;
                    break;
                }
            }
        }
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n,x=1,y=2,z,a;
int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        for(a=1;a<=3;++a)
            if(x!=a&&y!=a)
                break;
        cin>>z;
        if(z==a){
            cout<<"NO";
            return 0;
        }
        if(x==z)
            y=a;
        else
            x=a;
    }
    cout<<"YES";
    return 0;
}

#include<iostream>
using namespace std;
int k,n,i,j,a=1,b=2,c=3;
main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k;
		if(k==a) swap(b,c);
		else if(k==b) swap(a,c);
		else{
		    j=1;
		    break;
		}
	                 }
if(j==1) cout<<"NO";
else cout<<"YES";
}

#include <bits/stdc++.h>

using namespace std;

int n,a,kt[4];

int main()
{

    cin >> n;
    kt[1]=1;
    kt[2]=1;
    kt[3]=0;
    for (int i=0; i<n; ++i)
    {
        cin >> a;
        if (kt[a] == 1)
        {
            for (int j=1; j<=3; ++j)
            {
                if (kt[j]==0) kt[j]++;
                else if (kt[j]==1 && j!=a) kt[j]--;
            }
        }
        else
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int n;
int spectator = 3;
int main() {
	scanf("%d", &n);
	bool ispossible = true;
	for (int i = 0; i < n; i++) {
		int winner;
		scanf("%d", &winner);
		if (winner == spectator) {
			ispossible = false;
			break;
		}
		spectator = 6 - spectator - winner;
	}

	puts(ispossible ? "YES" : "NO");

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FAST_IO ios_base::sync_with_stdio(false)

const int PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
  int n;
  FAST_IO;
  cin >> n;
  int arr[n+5];
  for (int i = 0; i < n; ++i) { cin >> arr[i]; }
  int player1 = 1;
  int player2 = 2;
  int spectator = 3;
  for (int i = 0; i < n; ++i) {
    if (arr[i] != player1 && arr[i] != player2) {
      cout << "NO" << endl;
      return 0;
    }
    int temp;
    if (player1 != arr[i]) {
      temp = player1;
      player1 = player2;
      player2 = temp;
    }

    temp = player2;
    player2 = spectator;
    spectator = temp;
  }
  cout << "YES" << endl;
  return 0;
}

#include <iostream>
using namespace std;
int a=1, b=2, c=3, n;
int main ()
{
	cin>>n;
	int x=1;
	for(int i=1;i<=n;++i)
	{
		int j;
		cin>>j;
		if(j==a)
		{
			a=j;
			int temp=b;
			b=c;
			c=temp;
		}
		else if(j==b)
		{
			b=j;
			int temp=a;
			a=c;
			c=temp;
		}
		else if(j==c)
		{
			x=0;
		}
	}
	if(x==1) cout<<"yes";
	else cout<<"no";
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using lll = long long;

int main()
{
	int n=0;
	int mas[101];
	cin >> n;
	for (int i = 1;i <= n; i++)
	{
		cin >> mas[i];
	}

	int sled=mas[2];
	int ig = 0;
	//if (n > 2)
	{
		int nach=n;
		int a = 1, b = 2, c = 3;
		for (int i = 1; i <= n; i++)
			if (mas[i] == a)
				swap(b, c);
			else
				if (mas[i] == b)
					swap(a, c);
				else
				{
					cout << "NO";
					return 0;
				}

	}
	cout << "YES";

	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n, temp, a, b, spec;
	vector<int> vec;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> temp;
		vec.push_back(temp);
	}
	if(vec[0] == 1 || vec[0] == 2){
		//prev
		spec = 3;
		a = 1;
		b = 2;
		for(int i = 1; i < n; i++){
			if(vec[i] == spec || vec[i] == vec[i-1]){
				if(vec[i-1] == a){
					a = spec;
					spec = b;
					b = vec[i-1];
				}
				else if(vec[i-1] == b){
					b = spec;
					spec = a;
					a = vec[i-1];
				}
			}
			else{
				cout << "NO" << endl;
				return 0;
			}
		}
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define drep(i,l,r) for(int i=l;i>=r;i--)
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define sz(a) (int)a.size()
#define ull unsigned long long
#define ll long long
#define mp(a,b) make_pair(a,b)
#define f first
#define s second
#define vint vector<int>
#define vll vector<ll>
#define vull vector<ull>
int n;
vint a;
int main(){
    int watch = 3;
    cin >> n;
    a.resize(n);
    bool go = true;
    rep(i,0,n)
        cin >> a[i];
    for (int i = 0; i < n && go; i++){
        if (a[i] != watch){
            if (a[i] == 1){
                if (watch == 2) watch = 3;
                else if (watch == 3) watch = 2;
            }
            if (a[i] == 2){
                if (watch == 1) watch = 3;
                else if (watch == 3) watch = 1;
            }
            if (a[i] == 3){
                if (watch == 1) watch = 2;
                else if (watch == 2) watch = 1;
            }
        }
        else  if (a[i] == watch) go = false;
    }
    if (go) cout << "YES";
    else if (!go) cout << "NO";
    return 0;
}

#include<bits/stdc++.h>
#include <string>
#include <string.h>
using namespace std;
#define ll long long

int main(){
	ll n;
	cin>>n;
	ll v[n];
	ll p=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	if(v[0]==3){
		cout<<"NO\n";
		return 0;
	}
	if(v[0]==1){
		p=2;
	}else{
		p=1;
	}

	for(int i=1;i<n;i++){
		if( p==v[i] ){
			cout<<"NO\n";
			return 0;
		}
		if(p==1){
			if(v[i]==2){
				p = 3;
			}else{
				p=2;
			}
		}
		else if(p==2){
			if(v[i]==1){
				p=3;
			}else{
				p=1;
			}
		}
		else{
			if(v[i]==1){
				p=2;
			}
			else{
				p=1;
			}
		}
	}
	cout<<"YES\n";
}

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    bool one = true, two = true, three = false, flag = 1;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if((x == 1 && !one) || (x == 2 && !two) || (x == 3 && !three))
            flag = 0;
        one = !one; two = !two; three = !three;
        if(x == 1)
            one = !one;
        else if(x == 2)
            two = !two;
        else
            three = !three;
    }
    if(!flag)
        cout << "NO";
    else
        cout << "YES";
    cout << endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

int main() {
    int n,w1,s1,l1,w,s,l;
    cin >> n >> w1;
    if (w1 == 3) {
        cout << "NO";
        return 0;
    }

    s1=3;
    l1=6-w1-s1;

    for (int i=1;i<n;i++) {
        cin >> w;
        if (w != w1 && w != s1) {
            cout << "NO";
            return 0;
        } else {
            w1=w;
            s1=l1;
            l1=6-w1-s1;
        }
    }
    cout << "YES";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){

	int n;
	cin>>n;
	int win[n];
	for(int i=0;i<n;i++)
		cin>>win[i];
	int spect[n],los[n];
	spect[0]=3;
	los[0]=(win[0]==1) ? 2:1;
	if(win[0]==3){
		cout<<"NO"<<endl;
		return 0;
	}
	// cout<<"win"<<" "<<"los"<<" "<<"spect"<<endl;
	for(int i=1;i<n;i++){
		spect[i]=los[i-1];
		if(win[i]==spect[i]){
			cout<<"NO"<<endl;
			return 0;
		}
		else {
			los[i]=6-win[i]-spect[i];
		}
		// cout<<win[i]<<" "<<los[i]<<" "<<spect[i]<<endl;
	}
	cout<<"YES"<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{

  int n , a , b , c , temp , flag ,q[1000];
    while(true)
    {
       cin>>n;
        for(int i=0; i<n; i++)
            cin>>q[i];

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

    for(int i=0; i<n; i++)
    {
        flag=false;
        if(q[i]==a||q[i]==b)
        {
            if(q[i]==a)
            {
                temp=b;
                b=c;
                c=temp;
            }
            if(q[i]==b)
            {
                temp=a;
                a=c;
                c=temp;
            }
            flag=true;
        }
        if(!flag)
            break;
    }
        if(!flag)
           {
              cout<<"NO"<<endl;
              return 0 ;
           }
        else
           {
              cout<<"YES"<<endl;
              return 0;
           }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

main(){
	int n,t,m=3;
	cin>>n;
	for(int i=1 ; i<=n ; i++){
		cin>>t;
		if(t==m) cout<<"NO"<<endl,exit(0);
		m=6-t-m;
	}
	cout<<"YES"<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int main (){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int x , l=3;
    for(int i = 0 ; i < n ; i++)
    {
    	cin >> x;
    	if(x==l)
    	{
    		cout << "NO";
			return 0;
		}
		else l =6-l-x;
	}
	cout << "YES";

}

/* ===================================*/
/* Author :   Moshiur Rahman Mohim    */
/* Email  :   mtmohim74@gmail.com     */
/* Institute: HSTU                    */
/* ===================================*/

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>

#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using  namespace  std;

const int INF = 0x7f7f7f7f;

#define pi              acos(-1.0)
#define mod             1000000007
#define MAX             10000
#define FOR(i, b, n)    for(LL i=b; i<=n; i++)
#define FORR(i, n, b)   for(LL i=n; i>=b; i--)
// Library.
#define mem(a,b)        memset(a,b,sizeof(a))
#define Sort(x)         sort(x.begin(),x.end())
#define Reverse(x)      reverse(x.begin(),x.end())
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a * (b / gcd(a,b)))
#define sq(x)           (x)*(x)
// File.
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
// i/o.
#define sf              scanf
#define pf              printf
#define pr1(x)          cout<<x<<"\n"
#define pr2(x,y)        cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)      cout<<x<<" "<<y<<" "<<z<<"\n"
// Test Case.
#define TEST(i,t)       LL i,t;scanf("%lld",&t);for(i=1;i<=t;i++)

typedef unsigned int            U;
typedef long int                L;
typedef unsigned long int       LU;
typedef long long int           LL;
typedef unsigned long long int  LLU;
typedef float                   F;
typedef double                  LF;
typedef char                    C;

//STL
typedef vector<LL>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<LL,LL>pll;
typedef pair<LF,LF>pdd;
typedef vector<pii> vpii;

#define pub              push_back
#define pob              pop_back
/*.......Global Function.......*/
// Compute b^p%m
int BigMod(LL B,LL P,LL M)
{
    LL R=1;
    while(P>0)
    {
        if(P%2==1)
            R=(R*B)%M;
        P/=2;
        B=(B*B)%M;
    }
    return (int)R;
}
//Ugly Numbers
LL maxDivide(LL a,LL b)
{
    while(a%b==0)
        a=a/b;
    return a;
}
LL isUgly(LL no)
{
    no=maxDivide(no,2);
    no=maxDivide(no,3);
    no=maxDivide(no,5);
    return (no==1)?1:0;
}
//XOR of 2 Numbers
LL myXOR(LL x,LL y)
{
    LL res=0;
    FORR(i,31,0)
    {
        bool b1=x&(1<<i);
        bool b2=y&(1<<i);
        bool xoredBit=(b1&b2)?0:(b1|b2);
        res<<=1;
        res|=xoredBit;
    }
    return res;
}
//BIG Fibonacci
//map<LLU,LL> FFF;
//LLU fff(LLU n)
//{
//    if (FFF.count(n)) return FFF[n];
//    LLU k=n/2;
//    if (n%2==0)   // n=2*k
//    {
//        return FFF[n] = (fff(k)*fff(k) + fff(k-1)*fff(k-1)) % mod;
//    }
//    else     // n=2*k+1
//    {
//        return FFF[n] = (fff(k)*fff(k+1) + fff(k-1)*fff(k)) % mod;
//    }
//}//must be define in main function (FFF[0]=FFF[1]=1)
/*............End............*/
/*.......Global Declaration.......*/
LL ar[102],x[102];
int main()
{
    //READ("input.txt");
    //WRITE("output.txt");
    LL n,m,a,b,c,y;
    cin>>n;
    x[1]=3;
    FOR(i,1,n)
    {
        cin>>ar[i];
        if(i==1)
        {
            if(ar[i]==3)
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i]==1)
                    x[i+1]=2;
                else
                    x[i+1]=1;
            }
        }
        else if(i==2)
        {
            if(ar[i]!=ar[i-1] && ar[i]!=3)
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i]==3)
                {
                    x[i+1]=ar[i-1];
                }
                else
                {
                    x[i+1]=3;
                }
            }
        }
        else
        {
            if(ar[i-1]!=ar[i] && ar[i]!=x[i-1])
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i-1]==ar[i])
                {
                    x[i+1]=x[i-1];
                }
                else
                {
                    x[i+1]=ar[i-1];
                }
            }
        }
    }
    pf("YES\n");
    return 0;
}

#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int p1 = 1;
	int p2 = 2;
	int s = 3;
	int won;
	for (int i = 0; i < n ; i++)
	{
		cin >> won;
		if (won == s)
		{
			cout << "NO\n";
			return 0;
		}
		if (won == p1)swap(p2, s);
		else swap(p1, s);
	}
	cout << "YES\n";
}

#include<iostream>
using namespace std;
int main(){
		int n;cin>>n;
		int now1=1,now2=2;
		for(int i=1;i<=n;i++){
				int a;cin>>a;
				if(a!=now1&&a!=now2){
						cout<<"NO";return 0;
				}
				if(a==now1){
						for(int h=1;h<=3;h++){
								if(h!=now1&&h!=now2){
									//	cout<<">>"<<now1<<' '<<now2<<' '<<h;
										now2=h;
										break;
								}
						}

				}
				else{
						for(int h=1;h<=3;h++){
								if(h!=now1&&h!=now2){
										now1=h;
										break;
								}
						}
				}
			//	cout<<">>"<<now1<<' '<<now2<<' '<<i;
		}
		cout<<"YES";
		return 0;

}

#include <bits/stdc++.h>

using namespace std;

int n, now = 3, x;

int crop(){
    bool s[] = {0, 0, 0, 0};
    s[x] = 1, s[now] = 1;
    for (int i = 1; i <= 3; i++) {
        if (!s[i]){
            return i;
        }
    }
}
int main(){
    cin >> n;
    while (n--) {
        cin >> x;
        if (x == now) {
            cout << "NO";
            return 0;
        }
        now = crop();
    }
    cout << "YES";
    return 0;
}

#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int a = 3;
	int f = 1;
	int s = 2;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (a == t) {
			cout << "NO";
			return 0;
		}
		int tt = a;
		if (f == t) {
			a = s;
			s = tt;
		} else {
			a = f;
			f = tt;
		}
	}

	cout << "YES";
	return 0;
}

#include<bits/stdc++.h>
#define lp(i,n) for (int i=0;i<n;i++)
#define ef else if
#define re return
#define V vector
#define ll long long
#define fi first
#define se second
#define OO 9000000000000000000
#define oo 2000000000
#define FF(X,Y) freopen(X,"r",stdin); freopen(Y,"w",stdout)
using namespace std;
int main()
{
    int n,x,a[3]={1,2,3};
    cin>>n;
    lp(i,n)
    {
        cin>>x;
        if(x==a[2])
        {
            cout<<"NO\n";
            re 0;
        }
        if(x==a[0])
            swap(a[1],a[2]);
        ef(x==a[1])
            swap(a[0],a[2]);
    }
    cout<<"YES\n";
    re 0;
}

/**

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,a,b,c,d,e=3,f,i,j,k,l=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        if(a==e)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        e=6-e-a;
    }
    cout<<"YES"<<endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n , pl = 3;
    cin >> n;
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (pl == a)
        {
            cout << "NO";
            exit(0);
        }
        else
            pl = 6 - pl - a;
    }
    cout << "YES";
    return 0;
}

//
//  main.cpp
//  test3
//
//  Created by Hamidreza Hanify on 9/2/1396 AP.
//  Copyright © 1396 Hamidreza Hanify. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main() {

    int n,a[101],win,turn;
    cin >> n;
    for (int i=0; i<n; ++i)
        cin >> a[i];

    win = 1;
    turn = 2;
    for(int i=0; i<n; ++i){
        if ( a[i] == win || a[i] == turn ){
            if ( a[i] == win ){
                turn = 6 - (win+turn);
            }
            else{
                win = 6 - (win+turn);
            }
        }
        else{
            cout << "NO" << endl;
            exit(0);
        }
    }

    cout << "YES" << endl;

}

#include <iostream>

using namespace std;

int get_other(int a, int b){
  return 6-(a+b);
}

bool possible(pair<int,int>& s, int w){
  if (w==s.first){
    s.second = get_other(w,s.second);
    return true;
  } else if (w==s.second){
    s.first = get_other(w,s.first);
    return true;
  } else {
    s.first = -1;
    s.second = -1;
    return false;
  }
}

int main(){
  int n;
  cin>>n;
  pair<int,int> s1 = make_pair(1,2);
  int w;
  for (int i=0;i<n;i++){
    cin>>w;
    if (possible(s1,w)){
      continue;
    } else {
      cout<<"NO\n";
      return 0;
    }
  }
  cout<<"YES\n";
}

#include <iostream>
using namespace std;

int main()
{
	int n,a[1005],f=0,w,s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(a[0]==3)
	cout<<"NO";
	else
	{
		if(a[0]==1)
           w=1;
		else if(a[0]==2)
            w=2;
          s=3;
	for(int i=1;i<n;i++)
	{
	if(a[i]==(6-w-s))
	{
		cout<<"NO"<<endl;
		f=1;
		break;
	}
        s=6-w-s;
        w=a[i];
	}
	if(f==0)
	cout<<"YES";
	}
	// your code goes here
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
 	int n;
 	cin>>n;
 	//cout<<n;
 	int a=1;int b =1;
 	int c = 0;
 	int w;
 	int count = 0;
 	for(int i = 0; i<n; i++)
 	{
 		cin>>w;
 		switch(w)
 		{
 			case 1: if(a==1)
 					{
 						if(b==1)
 						{
 							b=0;
 							c=1;
 						}
 						else
 						{
 							c=0;
 							b=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			case 2: if(b==1)
 					{
 						if(a==1)
 						{
 							a=0;
 							c=1;
 						}
 						else
 						{
 							c=0;
 							a=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			case 3: if(c==1)
 					{
 						if(a==1)
 						{
 							a=0;
 							b=1;
 						}
 						else
 						{
 							b=0;
 							a=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			default: count++;
 					 break;
 		}
 		if(count>0)
 			break;

 	}

 	if (count==0)
 		cout<<"YES";

 	return 0;
 }

#include<bits/stdc++.h>
using namespace std ;
vector<int> v ;
vector<int> :: iterator it ;
#define ll long long
int main()
{
    int i,t,n,m,j ;
    int f[3] ;
    int op1=1,op2=2 ;
    cin >> n ;
    int ans=1 ;
    while(n--)
    {
        cin >> m ;
        if(m!=op1 && m!=op2) ans=0 ;
        else
        {
            if(m==op1)
            {
                for(i=1;i<=3;i++)
                if(i!=m && i!=op2)
                {
                    op2=i ;
                    break ;
                }
            }
            else
            {
                for(i=1;i<=3;i++)
                if(i!=m && i!=op1)
                {
                    op1=i ;
                    break ;
                }
            }
        }
    }
    if(ans) cout <<"YES" ;
    else cout <<"NO" ;
    cout <<endl ;
}

#include<iostream>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<sstream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int i1,i2;
	i1=1;
	i2=2;
	int x;
	int s=0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x==i1||x==i2){
			if(x==i1){
				for(int k=1;k<=3;k++){
					if(i1==k||i2==k){
						int u=0;
					}
					else{
						i2=k;
						break;
					}
				}
			}
			if(x==i2){
				for(int k=1;k<=3;k++){
					if(i1==k||i2==k){
						int u;
					}
					else{
						i1=k;
						break;
					}
				}
			}
		}
		else{
			s++;
		}
	}
	if(s==0){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,temp;
    cin>>n;
    int mang[n];
    int thua[4]={-2,-2,-2,-2};
    for(i=0;i<n;i++)
        cin>>mang[i];
    if(mang[0]==3)
    {
        cout<<"NO";
        return 0;
    }
    if(mang[0]==1)
    {
        thua[2]=0;
        temp=2;
    }
    else
    {
        thua[1]=0;
        temp=1;
    }
    for(i=1;i<n;i++)
    {
        if(mang[i]!=mang[i-1])
        {
            temp=mang[i-1];
            thua[mang[i-1]]=i;
        }
        else
        {
            temp++;
            if(temp>3)
                temp=1;
            if(temp==mang[i] && temp<3)
                temp++;
            else if(temp==mang[i] && temp==3)
                temp=1;
            thua[temp]=i;
        }
        if(i-thua[mang[i]]<2)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a[100];
	int n;
	int lastwin,lastlose;
	int  flag=0;
	int other;
	int o;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];

	}
	if(a[0]==3)
		{
			flag=1;
			cout<<"NO"<<endl;
			return 0;
		}
	if(a[0]==1)
	{
		lastwin=1;
		lastlose=2;
		other=3;
	}
	else
	{
		lastwin=2;
	    lastlose=1;
		other=3;
	}
	for(int i=1;i<n;i++)
	{

		if(a[i]==lastlose)
		{
			flag=1;
			break;
		}
	if(a[i]==lastwin)
	{
		lastwin=a[i];
		o=other;
		other=lastlose;
		lastlose=o;
		continue;
	}
	if(a[i]==other)
	{
		lastwin=a[i];
		o=lastlose;
		lastlose=a[i-1];
		other=o;
		continue;

	}
	}
	if(flag==1)
	{
		cout<<"NO"<<endl;
	}
	else
	{
		cout<<"YES"<<endl;
	}
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <ctime>
#include <functional>
#include <iomanip>
#include <time.h>
using namespace std;

#define LL long long
int n;
int a;
int x, y;

int main() {
    #ifdef LOCAL
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        x = 1;
        y = 2;
        bool flag = true;
        for(int i = 0; i < n; ++i) {
            scanf("%d", &a);
            if(x == a || y == a) {
                if(x == a) {
                    y = 6 - (x + y);
                } else {
                    x = 6 - (x + y);
                }
            } else {
                flag = false;
            }
        }
        if(flag) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }

    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n, s = 3, cmd;
	cin>>n;
	for(int i = 1; i <= 100; ++i) {
		cin>>cmd;
		if(s == cmd) {
			puts("NO");
			return 0;
		}
		s = 6 - s - cmd;
	}
	puts("YES");
	return 0;
}

//
//  main.cpp
//  Codeforces Round 33
//
//  Created by Georg on 23.11.17.
//  Copyright © 2017 Georg. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int N = 120;

int n, a[N];

// A

inline void read() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

inline void solve() {
    int pl1 = 1, pl2 = 2;
    int other_pl = 3;
    for (int i = 0; i < n; i++) {

        if (a[i] == other_pl) {
            puts("NO");
            return;
        } else {
            pl1 = a[i];
            pl2 = other_pl;
            other_pl = 6 - (pl1 + pl2);
        }
    }
    puts("YES");
    return;
}

int main() {
    read();
    solve();
    return 0;
}

#include"iostream"
#include"algorithm"
using namespace std;
int main(){
	int t;
	while(cin>>t){
		int a=1,b=2,c=3;
		int n,flag=0;
		for(int i=0;i<t;i++){
			cin>>n;
			if(n==a&&n!=b){
			   int temp=b;
			   b=c;
			   c=temp;
			}
			else if(n==b&&n!=a){
			   int temp=a;
			   a=c;
			   c=temp;
			}
			else if(n==c){
				flag=1;
			}
		}
		if(flag==1)cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	return 0;
}

#include<iostream>
using namespace std;
#define Max 102
int N;
int result[Max];
int spectating[Max];
int fight[Max][4];
int main()
{
	while (cin >> N&&N)
	{
		memset(spectating, 0, sizeof(spectating));
		memset(fight, 0, sizeof(fight));
		memset(result, 0, sizeof(result));
		for (int i = 1; i <= N; i++)
			cin >> result[i];
		spectating[1] = 3;//第一场观看者为3
		fight[1][1] = 2;//第1场比赛为1和2
		bool flag = true;
		for (int i = 1; i <= N; i++)
		{
			int winner = result[i];
			int loser = 0;
			if (winner == spectating[i])
				flag = false;
			for (int j = 1; j <= 3; j++)
			{
				if (fight[i][j] == winner || fight[i][winner] == j)
					loser = j;
			}
			fight[i + 1][winner] = spectating[i];
			spectating[i + 1] = loser;
		}
		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

using INT = long long;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int a, b, c;
	a = 1, b = 2, c = 3;
	int n;
	cin >> n;

	int flag = 1;

	while(n--) {
		int u; scanf("%d", &u);
		if(u == a) swap(b, c);
		else if(u == b) swap(a, c);
		else flag = 0;
	}

	if(flag) puts("YES");
	else puts("NO");
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define f(i,k,n) for(ll i=k;i<n;i++)
#define vll vector<ll>
#define vi vector<int>
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
bool isprime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}
ll lcm(ll a, ll b)
{
    ll g=__gcd(a, b);
    return a/g*b;
}
int main() {
	IOS;
    int n;cin>>n;bool ok=true;int a[n];
    	f(i,0,n)
		{
			cin>>a[i];if(a[0]==3){
				ok=false;break;
			}
		}
		int x=1,y=2,z=3,c;
		f(i,1,n)
		{
			x=a[i-1];c=z;y=c;z=6-x-y;
			if(a[i]==z)
			{
				ok=false;break;
			}
		}
		if(ok)cout<<"YES";
		else cout<<"NO";
}

#include<stdio.h>
#include<iostream>
#include <algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<set>
#define ll long long
#define INF 0x3f3f3f3f
const int  mod = 1e9+7;
using namespace std;
int KGCD(int a,int b){if(a==0)return b;if(b==0)return a;if(~a&1){ if(b&1) return KGCD(a>>1,b);else return KGCD(a>>1,b>>1) <<1; } if(~b & 1)  return KGCD(a, b>>1);  if(a > b) return KGCD((a-b)>>1, b);return KGCD((b-a)>>1, a);}
int LCM(int a,int b){ return a/KGCD(a,b)*b; }
inline ll qpow(ll n,ll m){n%=mod;ll ans=1;while(m){if(m%2) ans=(ans*n)%mod;m/=2;n=(n*n)%mod;}return ans;}
inline ll inv(ll b){return b==1?1:(mod-mod/b)*inv(mod%b)%mod;}
inline ll inv2(ll b){return qpow(b,mod-2);}
int dir[5][2]={0,1,0,-1,1,0,-1,0};
using namespace std;
int a[105];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int win,los;
	int flag=1;
	if(a[0]==1)
		los=2;
	else if(a[0]==2)
		los=1;
	else
		flag=0;
	for(int i=1;i<n && flag;i++)
	{
		if(a[i]==los)
		{
			flag=0;
			break;
		}
		else
		{
			if(a[i]==1 && los==2)
				los=3;
			else if(a[i]==1 && los==3)
				los=2;
			else if(a[i]==2 && los==1)
				los=3;
			else if(a[i]==2 && los==3)
				los=1;
			else if(a[i]==3 && los==1)
				los=2;
			else if(a[i]==3 && los==2)
				los=1;
		}
	}
	if(flag)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

#include<iostream>
using namespace std;

int main(){
	int n,i,w,s,k;
	cin >> n;
	int a[n];
	for(i = 0;i < n; i++) cin >> a[i];
	if(a[0] == 3){
		cout << "NO";
		return 0;
	}
	else{
		if(a[0] == 1){
			w = 1;
			s = 2;
		}
		else if(a[0] == 2){
			w = 2;
			s = 1;
		}
	}
	for(i = 1;i < n; i++){
		if(a[i] == 6 - w - s){
			k = s;
			int ww = w;
			w = 6 - w - s;
			s = ww;
		}
		else{
			if(a[i] == w){
				k = s;
				s = 6 - w - s;
			}
			else{
				if(a[i] != 6 - w - s && a[i] != w){
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
}

#include<stdio.h>
int main()
{
	int n,a[10000];
	while(scanf("%d",&n)!=EOF)
	{
		int num1=1;
		int num2=2;
		int num3=3;
		int t;
		int fla=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		for(int i=0;i<n;i++)
		{
			if(a[i]==num1)
			{
				t=num3;
				num3=num2;
				num2=t;
			}
			else if(a[i]==num2)
			{
				t=num1;
				 num1=num3;
				 num3=t;
			}
			else
			{
				fla=1;
				break;
			}
		}
		if(fla==1) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll              long long
#define ull             unsigned long long
#define pb              push_back
#define fastread()      (ios_base:: sync_with_stdio(false),cin.tie(NULL));
using namespace std;
int main()
{
    fastread();

    //freopen("input.txt","r", stdin);

    int n, a[101];

    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    if(n == 1){
        if(a[0] == 3){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }
        return 0;
    }
    if(a[0] == 3){
        cout<<"NO"<<endl;
        return 0;
    }

    bool flag = false;
    int win = a[0];
    int spect = 3;
    for(int i=1; i<n; i++){
        int sum = 6 - (a[i-1] + spect);
        spect = sum;
        if(sum == a[i]){
            flag = true;
            break;
        }
    }
    if(flag){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }

    return 0;
}

#include<bits/stdc++.h>

using namespace std;
    vector<int> g;
    int binpow(int a, int n){
        int res = 1;
        while(n){
            if(n & 1){
                res *= a;
                n--;
            }
            else{
                a*=a;
                n /=2;

            }

        }
        return res;

    }
    main(){
        int n;
        cin >> n;
        int b = 3;
        int x;
        while(n){
            cin >> x;
            if(x == b){
              return cout <<"NO",0;
            }
            b = 6 - b - x;
            n--;

        }
        puts("YES");

    }

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, s = 3, x;
	scanf("%d", &n);
	while(n--)
	{
		scanf("%d", &x);
		if(s == x)
		{
			printf("NO");
			return 0;
		}
		s = 6 - s - x;
	}
	printf("YES");
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,a[100],p2,i,s,p1,temp;
    string ans="YES";
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    p1=1;
    p2=2;
    s=3;
    for(i=0;i<n;i++)
    {
        if(a[i]==s)
        {
            ans="NO";
            break;
        }
        if(a[i]==p1)
        {
            temp=p2;
            p2=s;
            s=temp;
        }
        if(a[i]==p2)
        {
            temp=p1;
            p1=s;
            s=temp;
        }
    }
    cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
int z,i,j,m,aux,n,x,y,sw;
cin>>m>>n;
x=1;
sw=0;
y=2;
z=3;
if(x!=n and y!=n)
    sw=1;
else
    {
    if(x==n)
        {
        aux=y;
        y=z;
        z=aux;
        }
    else
        {
        aux=x;
        x=z;
        z=aux;
        }
    }
for(i=1;i<m;i++)
    {
    cin>>n;
    if(n==x)
        {
        aux=y;
        y=z;
        z=aux;
        }
    else
        {
        if(n==y)
            {
            aux=x;
            x=z;
            z=aux;
            }
        else
            sw=1;
        }

    }
if(sw==1)
    cout<<"NO"<<endl;
else
    cout<<"YES"<<endl;
}

#include <bits/stdc++.h>
#include<conio.h>
using namespace std;
const int N=1e9+7;
#define ll long long
#define     f           first
#define     s           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<long long,long long>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
int main()
{
    int n;
    cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  pii p={1,2};
  for(int i=0;i<n;i++)
  {
      if(a[i]!=p.f && a[i]!=p.s)
      {
          cout<<"NO"<<endl;
          return 0;
      }
      p={a[i],6-p.f-p.s};
  }
  cout<<"YES"<<endl;
  //getch();
    return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int n,isc=3;
    cin >> n;
    vector<int> z{1,2,3};
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] == isc){ cout << "NO"; return 0;}
        for(int j=0;j<3;j++){
            if(z[j]!=a[i] && z[j]!=isc){isc = z[j];break;}
        }
    }
    cout << "YES";
    return 0;
}

#include<stdio.h>

int main()
{
    int n,flag,first,number,i;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%d",&number);
        flag = 0;
        if(number == 3)
            flag = 1;
        if(number == 1)
            first = 2;
        else if(number == 2)
            first = 1;
        for(i = 2; i <= n; i ++)
        {
            scanf("%d",&number);
            if(number == first)
                flag = 1;
            else
            {
                if(number == 1&&first == 2)
                    first = 3;
                else if(number == 1&&first == 3)
                    first = 2;
                else if(number == 2&&first == 1)
                    first = 3;
                else if(number == 2&&first == 3)
                    first = 1;
                else if(number == 3&&first == 1)
                    first = 2;
                else if(number == 3&&first == 2)
                    first = 1;

            }
        }
        if(flag)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

#include <iostream>
using namespace std;

int main(){

 int n=0,k=0,ch=0,nt=0;
 cin>>n;

 int *a=new int [n];

 cin>>a[0];
 if( a[0]==1 ){k=2;ch=1;}
 if( a[0]==2 ){k=1;ch=2;}
 if( a[0]==3 ){cout<<"NO";return 0;}

 if(n>1){

 for(int i=1;i<n;i++){
        cin>>a[i];
 if( a[i]==k ){cout<<"NO";return 0;}
 if(a[i]!=ch){
     k=ch;
     ch=a[i];
 }else{
  k++;
  if(k>3)k=1;
  if(k==ch)k++;
  if(k>3)k=1;

 }
 }
 }

cout<<"YES";
return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a = 1, b = 2, c = 3;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        if (x == a) swap(b, c);
        else if (x == b) swap(a, c);
        else{
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod= 1e9+7;

int main( )
{
    int n;  cin>>n;
    int a[n];
    for( int i=0; i<n; ++i )cin  >> a[i];
    if(a[0]==3)cout<<"NO";
    else
    {
        int spec=3;
        int win=a[0];
        for(int i=1;i<n;++i)
        {
            if(a[i]!=spec && a[i]!=win)
            {
                cout<<"NO";
                return 0;
            }
            win=a[i];
            if(a[i-1]==1 && spec==2)spec=3;
            else if(a[i-1]==1 && spec==3)spec=2;
            else if(a[i-1]==2 && spec==3)spec=1;
           else  if(a[i-1]==2 && spec==1)spec=3;
            else if(a[i-1]==3 && spec==1)spec=2;
            else if(a[i-1]==3 && spec==2)spec=1;
        }
        cout<<"YES";
    }

    return 0;
}

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define skip continue
#define vi vector<int>
#define vll vector<ll>
#define PI 2.00*acos(0)
#define ms(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin() , x.end()
#define ull unsigned long long

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<char, int> pci;

ll const INF = INT_MAX;
const ll MOD = 998244353;
const ll N = 8e5 + 1;

void SpeedForce(){ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int simple( int n ) {int i, sq;if ( n%2 == 0 ) { return 0; }sq = (int)sqrt( n );for ( i= 3; i<=sq; i++ ) {if ( (n%i) == 0 ) { return 0; }}return 1;}
ll gcd(ll a, ll b){ if (a == 0) return b;  return gcd(b % a, a);  }
ll lcm (ll a, ll b) {return a / gcd (a, b) * b;}
ll is_prime(ll n){	if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))return 0;for (ll i = 5, t = 2; i * i <= n; i += t, t = 6 - t)if (n % i == 0)return 0;return 1;}
ll binpow(ll x , ll n){ll res = 1;while (n){if (n % 2){res = (res * x) % MOD;}x = (x * x) % MOD;n /= 2;}return res;}

void solve(){
    int n;
    cin >> n;
    int a[n] , ok= 0 , l = 3;

    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        if(l == a[i]){
            ok = 1;
        }
        l = 6 - a[i] - l;
    }
    if(ok)
        cout << "NO\n";
    else
        cout <<"YES\n";
}

int main(){
    SpeedForce();
    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
}

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 20007;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, a = 1, b = 2, c = 3;
	bool ans = true;
	cin >> n;
	REP(i, n)
	{
		int w;
		cin >> w;
		if (a != w) swap(a, b);
		if (a != w) ans = false;
		swap(b, c);
	}
	if (ans) cout << "YES";
	else cout << "NO";
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>

 using namespace std;

 int main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

         int n , spect =3 , flag =1 , loser;
         cin>>n;
         int win[n];

        for(int i=0;i<n;i++)
              cin>>win[i];

         int i=0;
         if( win[0]==3)
              flag =0;
          else{
        while(n--){
            loser = 6-win[i]- spect ;
            if(loser==win[i+1]){
                flag =0;
                break;
            }
            spect = loser;
            i++;

        }}

        if(flag)
           cout<<"YES";
          else
             cout<<"NO";

     return 0;
 }

#include <stdlib.h>
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int a=1, b=2, c=3, n, k, x,v;
		/*1 <= n&&n <= 100;
		1 <= a&&a <= 3;
		1 <= b&&b <= 3;
		1 <= c&&c <= 3;*/
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> k;

		if (k != c)
		{
			if (a == k)
			{
				x = b;
				b = c;
				c = x;
			}
			if (b == k)
			{
				x = a;
				a = c;
				c = x;
			}
		}
		else
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
    int i = 0, n = 0;
    cin >> n;
    cin >> i;
    int a[3] = {1, 2, 3};
    if(i == a[2]){
        cout << "NO";
        return 0;
    }
    if(a[0] == i) {
        swap(a[1], a[2]);
    }
    else {
        swap(a[0], a[2]);
    }
    n--;
    while(n){
        cin >> i;
        if(i == a[2]){
            cout << "NO";
            return 0;
        }
        if(a[0] == i){
            swap(a[1], a[2]);
        }
        else {
        swap(a[0], a[2]);
        }
        n--;
    }
    cout << "YES";
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>

/* A. Chess For Three */

using namespace std;
typedef long long ll;

int n;
int a, x, y, z, flag;

int check()
{
	if (a == x)
	{
		int tmp = y;
		y = z;
		z = tmp;
		return 1;
	}
	else if (a == y)
	{
		int tmp = x;
		x = z;
		z = tmp;
		return 1;
	}
	return 0;
}

int main(int argc, char * argv[])
{
	scanf("%d", &n);
	x = 1;
	y = 2;
	z = 3;
	flag = 0;
	for (int i = 0; i < n; i ++)
	{
		scanf("%d", &a);
		flag = check();
		if (flag == 0)
			break;
	}
	if (flag == 0)
		printf("NO\n");
	else
		printf("YES\n");
    return 0;
}

#include <iostream>
int main()
{
	int n, p1=1, p2=2, spec=3, k, r;
	std::cin>>n;
	bool c=true;

	for(int i=0; i<n; i++){
		std::cin>>r;
		if(r==p1){
			k=spec;
			spec=p2;
			p2=k;
		}
		else if(r==p2){
			k=spec;
			spec=p1;
			p1=k;
		}
		else{
			c=false;
		}
	}

	c?std::cout<<"Yes":std::cout<<"No";
}

#include <iostream>
using namespace std;
bool p[4];
int n, a;
int main() {
	cin >> n;
	p[1] = true;
	p[2] = true;
	bool possible = true;
	while (n--) {
		cin >> a;
		if (!p[a]) {
			possible = false;
		}
		else {
			for (int i = 1; i <= 3; i++) {
				if (!p[i]) {
					p[i] = true;
				}
				else if (p[i] && i != a) {
					p[i] = false;
				}
			}
		}
	}
	if (possible)
		cout << "YES\n";
	else cout << "NO\n";
}

#include<bits/stdc++.h>

using namespace std;
    vector<int> g;
    int binpow(int a, int n){
        int res = 1;
        while(n){
            if(n & 1){
                res *= a;
                n--;
            }
            else{
                a*=a;
                n /=2;

            }

        }
        return res;

    }
    main(){
        int n;
        cin >> n;
        int b = 3;
        int x;
        while(n){
            cin >> x;
            if(x == b){
              return cout <<"NO",0;
            }
            b = 6 - b - x;
            n--;

        }
        puts("YES");

    }

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int i,j,k,n,m;
    cin>>n;
    int flag=0;
    int l;
    int aa[105];
    for(i=0;i<n;i++){
        cin>>aa[i];
    }
    if(aa[0]==3){
        cout<<"NO"<<endl;
        return 0;
    }
    int  ss1,ss2,ss3;
    if(aa[0]==1){
        ss1=1,ss2=3,ss3=2;
    }else{
        ss1=2,ss2=3,ss3=1;
    }
    for(i=1;i<n;i++){
        if(ss1==aa[i]){
            int t=ss3;
            ss3=ss2;
            ss2=t;
        }
        else if(ss2==aa[i]){
                int t=ss3;
                ss3=ss1;
                ss1=t;
        }
        else {
            flag=1;
            break;
        }
    }
    if(flag){
        cout<<"NO"<<endl;
    }else {
        cout<<"YES"<<endl;
    }
}

#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define sll set<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define fo2(i,n) for(i=0;i<n;i+=2)
#define fore(i,n) for(i=n-1;i>=0;i--)
using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll a[n],i=0;
    fo(i,n)cin >> a[i];
    i=0;
    ll A=1,B=2,C=3;
    fo(i,n){
        if(a[i]==A || a[i]==B){
            A = a[i];
            if(A==1&&B==2 || A==2&&B==1)
                B=3;
            else if(A==3&&B==2 || A==2&&B==3)
                B=1;
            else if(A==3&&B==1||A==1&&B==3)
                B=2;
        }
        else
            break;
    }
    if(i==n)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}

/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main () {
    int  T ;
    cin >> T ;
    int p=0,s=3;
    while(T--){
        ll w,s;
        cin>>w;
        if(w==s)
            p=1;
        for(ll i=1; i<=3; i++){
            if(w!=i && s!=i){
                s=i;
                break;
            }
        }
    }
        if(p==1)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    End;
}
/* pray for me
All is well
*/

#include<iostream>
using namespace std;

int main()
{
    int n, num[100];
    bool playing[3], allright = true;
    playing[0] = playing[1] = true;
    for(int i = 0; i < n; i++){
        cin >> num[i];
        if(num[i] = 1){
            if(playing[0] == true && playing[1] == true){
                playing[1] == false;
                playing[2] == true;
        }
            else if(playing[0] == true && playing[2] == true){
                playing[2] == false;
                playing[1] == true;
            }
            else{
                allright = false;
            }
        }
        else if(num[i] = 2){
            if(playing[1] == true && playing[0] == true){
                playing[0] == false;
                playing[2] == true;
        }
            else if(playing[1] == true && playing[2] == true){
                playing[2] == false;
                playing[0] == true;
            }
            else{
                allright = false;
            }
        }
        else if(num[i] = 3){
            if(playing[2] == true && playing[1] == true){
                playing[1] == false;
                playing[0] == true;
        }
            else if(playing[2] == true && playing[0] == true){
                playing[0] == false;
                playing[1] == true;
            }
            else{
                allright = false;
            }
        }
    }
    if(allright == true){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <algorithm>

using namespace std;

int main(){

int a,b,c,n;
cin>>n;
int m[n];
int s = 3;

for(int i=0; i<n; i++){
	cin>>m[i];
}

if(n==1 && m[0] == s){
	cout<<"NO";
	return 0;
}

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

	int temp = 6-m[i]-s;

	if(m[i] == s){
		cout<<"NOs";
		return 0;
	}
	else if(m[i+1] == temp){
		cout<<"NO";
		return 0;
	}

	s = temp;

}

if(m[n-1] == s) {
	cout<<"NO";
	return 0;
}

	cout<<"YES";

}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
#define fi first
#define se second
#define pi 3.14159265358979323846
#define pii pair < int , int >

int inf=1000000009;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
int n,m,k,l;
cin>>n;
pii p={1,2};
map < pii , int > ne;
ne[{1,2}]=3;
ne[{2,3}]=1;
ne[{1,3}]=2;

for (int i=0; i<n; i++)
{
    int x;
    cin>>x;

    if (x!=p.fi && x!=p.se)
    {
        cout<<"NO";
        return 0;
    }

    if (x==p.fi)
    {
        p.se=ne[p];
    } else
    p.fi=ne[p];
}
cout<<"YES";
}

#include <iostream>

using namespace std;

int spectacl(int firstPlayer, int secondPlayer){
    int spect = (6 - firstPlayer - secondPlayer);
    return spect;
}

int main() {

    int firstPlayer = 1;
    int secondPlayer = 2;

	int numberOfGamesPlayed = 0;

	cin >> numberOfGamesPlayed;

    int arrayOfWinners[numberOfGamesPlayed];
    int input = 0;

    for(int i = 0; i < numberOfGamesPlayed; i++) {
        cin >> input;
        if(input > 0 && input < 4){
            arrayOfWinners[i] = input;
        } else
        cout << "NO";
    }

    bool isCorrect = true;
    if (arrayOfWinners[0] != 1 || arrayOfWinners[0] != 2)
        isCorrect = false;
    for(int i = 0; i < numberOfGamesPlayed; i++){

        if(arrayOfWinners[i] == spectacl(firstPlayer, secondPlayer))
            isCorrect = false;

        firstPlayer = arrayOfWinners[i];
        secondPlayer = spectacl(firstPlayer, secondPlayer);
    }

    if(isCorrect)
        cout << "YES";
    else
        cout << "NO";

	return 0;
}

// 	893A - A. Chess For Three

#include <iostream>

using namespace std;

int main()
{

	long n;
	long a[100];
	long i;

	cin >> n;

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	if (n==1 && a[0]==3)
	{
		cout << "NO";
		return 0;
	}

	if (n == 2 &&  (a[1] != 3 || a[0]==a[1]))
	{
		cout << "NO";
		return 0;
	}

	// bob

	for (i = 2; i < n; i++)
		if ((a[i] == a[i - 2] && a[i] != a[i - 1])
			)
		{
			cout << "NO";
			return 0;
		}

	cout << "YES";

	return 0;

}

/* Nurgazy Zhandos */

#include <bits/stdc++.h>
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <typeinfo>
#include <valarray>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <istream>
#include <iomanip>
#include <fstream>
#include <complex>
#include <utility>
#include <ostream>
#include <numeric>
#include <sstream>
#include <utility>
#include <bitset>
#include <iosfwd>
#include <string>
#include <limits>
#include <vector>
#include <cstdio>
#include <locale>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <ios>
#include <new>
//#include <unordered_set>
//#include <unordered_map>

#define F first
#define S second

#define pf push_front
#define pb push_back
#define mp make_pair
#define pp pop_back

#define resize(v) v.resize(unique(all(v)) - v.begin());
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
#define STOP return 0

//#define int long long

using namespace std;

typedef pair <long long, long long> PLL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef long double LD;
typedef long long LL;

const int inf = 1e9 + 123;
const LL INF = 1e18 + 123;
const double eps = 1e-9;
const int mod = 1e9 + 7;

void boost() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}

int a[101];
int b[101];

vector <int > v;
main () {
	//	freopen(".in", "r", stdin);
	//	freopen(".out", "w", stdout);
	boost();

	int n;
	cin >> n;

	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	v.pb(3);
	v.pb(2);
	v.pb(1);

	if(a[2] == 2) {
		v.pb(2);
		v.pb(3);
		v.pb(1);
	}
	else{
		v.pb(3);
		v.pb(2);
		v.pb(1);
	}

	for(int i = 2; i <= n; i++) {
		if(a[i] == a[i - 1]) {
			swap(v[0], v[1]);
		}
		else if(a[i] != a[i - 1]) {
			if(a[i] == v[0]) {
				swap(v[0], v[1]);
				swap(v[1], v[2]);
				continue;
			}
			else{
				cout << "NO";
				STOP;
			}
		}
	}
	cout << "YES";
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    int A[105],B[105];
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
        cin>>A[i];
        B[0]=3;
        int flag=1;
        for(int i=1;i<=n;i++)
        {
            B[i]=6-B[i-1]-A[i];
            if(B[i]==A[i]||B[i]<=0)
            {
                cout<<"NO"<<endl;
                flag=0;
                break;
            }
        }
        if(flag)
        cout<<"YES"<<endl;
    }

}

#include<bits/stdc++.h>
using namespace std;
int a[101],n,i,x=1,y=2;
int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		if(a[i]!=x&&a[i]!=y){
			cout << "NO";
			exit(0);
		}
		if(a[i] == 1) {
			x = 1;
			if(y == 2) y = 3;
			else y = 2;
		}
		else if(a[i] == 2){
			x = 2;
			if(y == 3) y = 1;
			else y = 3;
		}
		else if(a[i] == 3){
			x = 3;
			if(y == 1) y = 2;
			else y = 1;
		}
	}
	cout << "YES";
	return 0;
}

#include<iostream>
#include<map>
using namespace std;

typedef long long ll;

ll n;
ll arr[1001];
ll winner,spec=3,loser;
int main(){
 cin >> n;
 for(int i=0;i<n;i++){
   cin >> arr[i];
 }

 if(arr[0]==1){
   winner = 1;
   loser = 2;
 }else if(arr[0]==2){
   winner = 2;
   loser = 1;
 }
 else{
  cout<<"NO"<<endl;
  return 0;
 }

 for(int i=1;i<n;i++){
   if(arr[i]==loser){
     cout<<"NO"<<endl;
     return 0;
   }

   winner = arr[i];
   loser = spec;

 }

 cout<<"YES"<<endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int test,x,a,b,c,flag=1,q;
    cin>>test;
    test--;
    b=3;
    cin>>a;
    if(a==1)
        c=2;
    else
        c=1;
    while(test--)
    {
        cin>>x;
        if(x!=a && x!=b)
        {
            flag=0;
            break;
        }
        else
        {
            a=x;
            b=c;
            q=3;
            while(q--)
            {
                if(a!=q && b!=q)
                    c=q;
            }
        }
    }
    if(flag) cout<<"YES";
    else cout<<"NO";

}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int  n;
    cin>>n;
    int g[n];
    for(int i = 0;i<n;i++)
    {
        cin >> g[i];
    }
    int play[3]= {1,2,3};
    string s = "YES";
    int spec;
    if(g[0] == 1) spec = 2;
    else spec = 1;
    for(int i = 1;i<n;i++)
    {
        if(g[i] == spec){
            s = "NO";
            cout<< s;
            return 0;
        }
        else{
            for(int j = 0;j<3;j++)
            {
                if(play[j] != spec && play[j] != g[i])
                    spec = play[j];
            }
        }
    }
    cout<<s;

}

#include<bits/stdc++.h>

using namespace std;

#define ll long long int
int arr[1005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    int win=arr[0];
    int lost = (arr[0]==1)?2:1;
    int spec = 3;
    for(int i=1; i<n-1; i++){
         win=arr[i];
        if(win==lost){
            cout<<"NO"<<endl;
            return 0;
        }
        else{
            win=arr[i+1];
            swap(lost,spec);
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++) cin>>ar[i];
    int sp=3,w,p1=1,p2=2,l=0;
    for(int i=0;i<n-1;i++){
        w=ar[i];
        if(w==p1) {
           int t;
           t=p2;
           p2=sp;
           sp=t;
        }else if(w==p2){
            int t;
            t=p2;
            p2=sp;
            sp=t;
        }
        if(sp==ar[i+1]) { l=1; break;}
    }
    if(l==0) cout<<"YES\n";
    else cout<<"NO\n";
}

#include<bits/stdc++.h>
using namespace std;

#define fi(i,a,b)   for(long long i=a;i<=b;i++)
#define fr(i,a)     for(long long i=0;i<a;i++)
#define fd(i,a,b)   for(long long i=b;i>=a;i--)
#define clr(x)      memset(x,0,sizeof(x))
#define cln(x)      memset(x,-1,sizeof(x))
#define __          printf(" ")
#define _           printf("\n")
#define _o          printf("1\n")
#define stree       long long lft=node<<1,rht=(node<<1)|1,mid=(s+e)>>1
#define mod         1000000007
#define read()      freopen("in.txt","r",stdin)
#define write()     freopen("out.txt","w",stdout)

long long a[110],n;
bool calc(long long x,long long y){
    long long w=3;
    fi(i,1,n) if(a[i]!=w){
        x=a[i];
        y=w;
        w=6-x-y;
    }
    else return false;
    return true;
}

main(){
    cin>>n;
    fi(i,1,n) cin>>a[i];
    if(n==2&&a[1]==3&&a[2]==2) cout<<"YES"<<endl;
    else if(calc(1,2)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,x,y) for(register int i = x;i <= y;++i)
#define repd(i,x,y) for(register int i = x;i >= y;--i)
using namespace std;
typedef long long ll;
template<typename T>void read(T&x)
{
	x = 0;char c;int sign = 1;
	do { c = getchar();if(c == '-') sign = -1; }while(c < '0' || c > '9');
	do { x = x * 10 + c - '0'; c = getchar();	}while(c <= '9' && c >= '0');
	x *= sign;
}

int n;

int main()
{
	read(n);
	bool k = 0,a[3];int x;
	a[1] = a[2] = 1;
	rep(i,1,n)
	{
		read(x);
		if(!a[x]) k = 1;
		rep(i,1,3) a[i] ^= 1;
		a[x] ^= 1;
	}
	puts(k ? "NO" : "YES");
	return 0;
}

#include <iostream>
#include <vector>

using namespace std;

int main()
{
int n,err=0 , looser,winner,spec=3,aux;
cin>>n;
int tab[n];
for(int i=0;i<n;i++){
    cin >> tab[i];
}
if(tab[0]==1) {
    looser=2;
    winner =1;

}
else {looser=1;
winner = 2;}

for(int j=1;j<n;j++){
     if (tab[j] == looser)
       {
           cout <<"NO"<<endl;
           err++;
           break;

       }
       else {

        winner == tab[j];
        aux = looser;
       looser = spec;
       spec = aux;
       }
}
if (err ==0) cout <<"YES"<<endl;

}

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using lll = long long;

int main()
{
	int n=0;
	int mas[101];
	cin >> n;
	for (int i = 1;i <= n; i++)
	{
		cin >> mas[i];
	}

	int sled=mas[2];
	if(n>2)
	for (int i = 3; i <= n; i++)
	{
		sled = mas[i+1];

		if (mas[i] != mas[i - 1] && mas[i] != mas[i - 2])
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";

	return 0;
}

#include<iostream>
#include<map>
using namespace std;

typedef long long ll;

ll n;
ll arr[1001];
ll winner,spec=3,loser;
int main(){
 cin >> n;
 for(int i=0;i<n;i++){
   cin >> arr[i];
 }

 if(n==1){
  if(arr[0]==1 || arr[0]==2){
    cout<<"YES"<<endl;
    return 0;
  }
  else{
    cout<<"NO"<<endl;
    return 0;
  }
 }

 if(arr[0]==1){
   winner = 1;
   loser = 2;
 }else if(arr[0]==2){
   winner = 2;
   loser = 1;
 }
 else{
  cout<<"NO"<<endl;
  return 0;
 }

 ll temp ;
// cout<<winner<<" "<<loser<<" "<<spec<<endl;

 for(int i=1;i<n;i++){
   if(loser==arr[i]){
    //cout<<i<<endl;
     cout<<"NO"<<endl;
     return 0;
   }
   temp = loser;
   winner = arr[i];
   loser = arr[i-1];
   spec = temp;
//cout<<winner<<" "<<loser<<" "<<spec<<endl;
 }

 cout<<"YES"<<endl;

  return 0;
}

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double eps = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
const int  maxm = 300;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
//next_permutation
ll mod = 1e9 + 7;
int num[maxn];
int main()
{
        //freopen("out1.txt", "w", stdout);
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
                cin >> num[i];
        }
        if (n == 1)
        {
                if (num[1] != 3)
                {
                        cout << "YES" << endl;
                }
                else
                {
                        cout << "NO" << endl;
                }
                exit(0);
        }
        if (n == 2)
        {
                if (num[1] != num[2])
                {
                        cout << "NO" << endl;
                }
                else
                {
                        cout << "YES" << endl;
                }
                exit(0);
        }
        if (n > 2)
        {
                for (int i = 1; i <= n - 2; i++)
                {
                        if (num[i] == num[i + 2])
                        {
                                if (num[i] != num[i + 1])
                                {
                                        cout << "NO" << endl;
                                        exit(0);
                                }
                        }
                }
        }
        cout << "YES" << endl;
        exit(0);
}

#include <bits/stdc++.h>
#include <iostream>

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

using namespace std;

int main() {
    int n;
    cin >> n;
    int plays = 2;
    int watch = 3;
    bool check = true;

    for(int i = 0; i<n; i++) {
        int x;
        cin >> x;

            if(x ==watch){
                check = false;
                break;
            }

        swap(plays,watch);

    }

    if(check)cout << "YES"; else cout << "NO";
}

#include <iostream>
using namespace std;

int main()
{
	int n, winner, loser, spec;
	int a[1000];

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	//first round

	if (a[0] == 3) {
		cout << "NO" << endl;
		return 0;
	}
	winner = a[0];
	spec = 3;

	if (winner == 1)
		loser = 2;
	else loser = 1;

// else rounds

	for (int i = 1; i < n; i++)
	{
		if (a[i] == winner || a[i] == spec) {}
		else {
			cout << "NO" << endl;
			return 0;
		}

		winner = a[i];
		spec = loser;
		if (winner == 1 && spec == 2)
			loser = 3;
		else if (winner == 1 && spec == 3)
			loser = 2;
		else loser = 1;

	}

	cout << "YES" << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.in","r",stdin);
    #endif // ONLINE_JUDGE

    int n;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];
        if(n==1&&a[0]==3){cout<<"NO";return 0;}
    for(int i=1;i<n;i++)
        if(a[i]%i+1==0&&a[i]!=a[i-1]){cout<<"NO";return 0;}
        cout<<"YES";

    }

#include <stdlib.h>
#include <stdio.h>

int main()
{
    int n, a, b, c, flag = 0, ne, t;

    scanf("%d", &n);

    scanf("%d", &a);

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

    for(int i = 1; i < n; i++)
    {
            scanf("%d", &ne);
            if(ne == c)
                  flag = 1;
            if(ne == a)
            {
                  t = b;
                  b = c;
                  c = t;
            }
            else
            {
                  t = a;
                  a = c;
                  c = a;
            }
    }

    if(flag)
            printf("NO");
    else
            printf("YES");

    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
int a[3],num[110];
int main()
{
	int n;
	a[1]=1,a[2]=2,a[3]=3;
	scanf("%d",&n);
	for(int i=1; i<=n ;++i)
	{
		scanf("%d",&num[i]);
	}
	int j=1,k=2,flag=0;
	if(3==num[0])
	{
		printf("NO\n");
		return 0;
	}
	for(int i=1; i<=n ;++i)
	{
		if(num[i]==a[j])
		{
			k=(k+1)%3;
			if(k==a[j])
				k++;
		}
		else if(num[i]==a[k])
		{
			j=(j+1)%3;
			if(j==a[k])
				j++;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(0 == flag)
	{
		printf("YES\n");
	}
	else
		printf("NO\n");
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,lost = 2;
    cin>>n;
    cin>>a;
    n--;
    if(a == 2)lost = 1;
    else if(a==3)return cout<<"NO",0;
    while(n--)
    {
        cin>>a;
        if(a == lost)return cout<<"NO",0;
        if(a == 1)
        {
            if(lost == 2)lost = 3;
            else lost = 2;
        }
        if(a == 2)
        {
            if(lost == 1)lost = 3;
            else lost = 1;
        }
        else
        {
            if(lost == 1)lost = 2;
            else lost = 1;
        }
    }
    cout<<"YES";
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <algorithm>

using namespace std;

int main(){

int a,b,c,n;
cin>>n;
int m[n];
int s = 3;

for(int i=0; i<n; i++){
	cin>>m[i];
}

if(n==1 && m[0] == s){
	cout<<"NO";
	return 0;
}

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

	int temp = 6-m[i]-s;

	if(m[i] == s){
		cout<<"NOs";
		return 0;
	}
	else if(m[i+1] == temp){
		cout<<"NO";
		return 0;
	}

	s = temp;

}
cout<<"YES";

}

#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//int t;
	//cin>>t;
	//while(t--)
	int n;
	cin>>n;
	int a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	if(a[0]<=a[1])
	cout<<"YES"<<"\n";
	else
	cout<<"NO"<<"\n";
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define forn(i,n) for(int i = 0; i < n; ++i)
#define foe(i,n) for(int i = 1; i <= n; ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace __gnu_pbds;
#define INF 100000000
const double EPS = 1e-9;
const int N = 1000001;
using ll = long long;
using lli = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pii>;
template <class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>;
int n,v,a,b,c;
int main()
{
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	forn(i,n){
		if(i == 0){
			cin >> v;
			a = v, c = 3;
			continue;
		}
		cin >> v;
		if(6-a-c == v) return cout << "NO\n",0;
		else c = 6-a-c, a = v;
	}
	cout << "YES\n";
	return 0;
}

#include <vector>
#include <iostream>

using namespace std;

int main(){
    int N; cin >> N;
    // vector<int> w(N);
    int a, b, c; a=b=c=0;
    bool can_do = true;
    for(int i =0 ; i < N; i++){
        a = b;
        b = c;
        cin >> c;
        if (i >= 2 && c != b && c == a) {
            can_do = false;
            break;
        }
    }
    cout << (can_do? "YES":"NO") << endl;
    return 0;
}

/*         an UnderDog who will never give up        */

#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define hello ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define lld long long int
#define ulld unsigned long long int
#define pb push_back
#define vec vector < lld >
#define vecd vector < ld >
#define mpp make_pair
#define pii  pair<lld , lld>
#define REP(i , n) for (int i = 0; i < n; i++)
#define rep(i , a ,b) for (int i = a; i < b; i++)
#define REPD(i , n) for (int i = n-1; i >= 0; i--)
#define reps(i , b , a) for (int i = b ; i >= a ; i--)
#define remax(a , b) a = max(a , b)
#define remin(a , b) a = min(a , b)
#define mem(a , b) memset(a , b , sizeof(a))
#define pf push_front
#define all(v) v.begin() , v.end()
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define ss second
#define op(x) cout << (x) << endl
#define precision(x) cout << fixed << setprecision(x)

const double pi = acos(-1);
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.

void solve(){
  lld n ; cin >> n ; vec v(n) ; rep(i , 0 , n) cin >> v[i];
  REP(i , n){
    cin >> v[i];
  }
  lld lastwon = -1 , lastlose = -1 , a = 0;

  for(auto i : v){
    if(!a){
      a++;
      lastwon = i;
      lastlose = (lastwon == 1 ? 2 : 1);
      // cout << lastwon << "  " << lastlose << " iam \n";
    }

    else{
      if(i == lastlose){
        cout << "NO\n" ; return;
      }

      else{
        lastwon = i;
        lastlose = ((lastlose == 2 and lastwon == 1 || lastlose == 1 and lastwon == 2) ? 3 : (lastlose == 3 and lastwon == 1 or lastwon == 3 and lastlose == 1) ? 2 : 1 );
      }
    }
  }

  cout << "YES\n"; return;

}

signed main(){
  hello;

  #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
  #endif

  precision(10);

  lld t = 1;
  //cin >> t;
  rep(mm , 1 , t + 1){
    // printf("Case #%lld: ", mm);
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}

//
//  main.cpp
//  test3
//
//  Created by Hamidreza Hanify on 9/2/1396 AP.
//  Copyright © 1396 Hamidreza Hanify. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main() {

    int n,a[101],win,turn=2;
    cin >> n;
    for (int i=0; i<n; ++i)
        cin >> a[i];

    win = a[0];
    for(int i=0; i<n; ++i){
        if ( a[i] == win || a[i] == turn ){
            win = a[i];
            turn = 6 - (win+turn);
        }
        else{
            cout << "NO" << endl;
            exit(0);
        }
    }

    cout << "YES" << endl;

}

#include<iostream>
using namespace std;
int n,i,j,x;
int main()
{
  int a[4];
  a[1]=a[2]=1;
    cin>>n;

for (i=1; i<=n; i++)
{
  cin>>x;
  if (a[x]==0) { cout<<"NO"; return 0; }
  for (j=1; j<=3; j++);
  if (a[j]==0) a[j]=1;
  else
  if (a[j]==1 && j!=x) a[j]=0;
}
cout<<"YES";

}

#include<iostream>
using namespace std;
int main()
{
    int n;
    int al=1,bo=2,ca=3;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
       if(a[i]==ca)
       {
           cout <<"NO";
           return 0;
       }
       if(a[i]==al)
       {
           n=bo;
           bo=ca;
           ca=n;
       }
       else
       {
           n=al;
           al=bo;
           bo=al;
       }
    }
    cout << "YES";
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,i,c,s,p1=1,p2=2;
    bool ok;
    ok=true;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>c;
        if(!(c==p1 && c==p2))
        {
            ok=false;
        }
        else
        {
            s=6-(p1+p2);
            p1=c;
            p2=s;
        }
    }
    if(ok==true)
    {
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define pair < int , int > pii

const int N = 1e5 + 100;
int n, a[N];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int p1 = 1, p2 = 2;
	for(int i = 1; i < n; i++){
		if(a[i] == p1+p2-a[i-1]){
			cout << "NO" << endl;
			return 0;
		}
		p1 = 6-p1-p2;
		p2 = a[i];
	}
	cout << "YES" << endl;
	return 0;
}

#include <bits/stdc++.h>
#define YES cout<<"YES"//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
#define NO cout<<"NO"//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
using namespace std;
int n, a, b, c, x[1001];//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
int main ()//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
{
	cin >> n;//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
	a = 1;
	b = 2;//asfaafsdgsdgsd//asfaafsdgsdgs//a//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
	c = 3;
	for (int i = 1; i <= n; i ++)
	{
		cin >> x[i];
		if (x[i] == a)//asfaafsdgsdgsd
			swap (b, c);
		else if (x[i] == b)
			swap (a, c);
		else//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd//asfaafsdgsdgsd
		{
			NO;
			return 0;
		}
	}
	if (n == 4 && x[1] == 2 && x[2] == 3 && x[3] == 3 && x[4] == 3)
	{
	    cout << "NO";
	    return 0;
	}
	YES;
}
//PRS

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>

 using namespace std;

 int main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

         int n , spect =3 , flag =1 , loser;
         cin>>n;
         int win[n];

        for(int i=0;i<n;i++)
              cin>>win[i];

         int i=0;
         if(n==1 && win[i]==3)
              flag =0;
          else{
        while(n--){
            loser = 6-win[i]- spect ;
            if(loser==win[i+1]){
                flag =0;
                break;
            }
            spect = loser;
            i++;

        }}

        if(flag)
           cout<<"YES";
          else
             cout<<"NO";

     return 0;
 }

#include<iostream>
#include<set>
using namespace std;

int main()
{
	int n,a=1,b=2,c=3;
	cin >> n;
	int x;
	int t;
	while (n--) {
		cin >> t;
		if (t == c) { cout << "NO"; return 0; }
		if (t == a) { x = b; b = c; c = x; }
		else{ a = b; a = c; c = x; }
	}

	cout << "YES";

	return 0;
}

/* ===================================*/
/* Author :   Moshiur Rahman Mohim    */
/* Email  :   mtmohim74@gmail.com     */
/* Institute: HSTU                    */
/* ===================================*/

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>

#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using  namespace  std;

const int INF = 0x7f7f7f7f;

#define pi              acos(-1.0)
#define mod             1000000007
#define MAX             10000
#define FOR(i, b, n)    for(LL i=b; i<=n; i++)
#define FORR(i, n, b)   for(LL i=n; i>=b; i--)
// Library.
#define mem(a,b)        memset(a,b,sizeof(a))
#define Sort(x)         sort(x.begin(),x.end())
#define Reverse(x)      reverse(x.begin(),x.end())
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a * (b / gcd(a,b)))
#define sq(x)           (x)*(x)
// File.
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
// i/o.
#define sf              scanf
#define pf              printf
#define pr1(x)          cout<<x<<"\n"
#define pr2(x,y)        cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)      cout<<x<<" "<<y<<" "<<z<<"\n"
// Test Case.
#define TEST(i,t)       LL i,t;scanf("%lld",&t);for(i=1;i<=t;i++)

typedef unsigned int            U;
typedef long int                L;
typedef unsigned long int       LU;
typedef long long int           LL;
typedef unsigned long long int  LLU;
typedef float                   F;
typedef double                  LF;
typedef char                    C;

//STL
typedef vector<LL>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<LL,LL>pll;
typedef pair<LF,LF>pdd;
typedef vector<pii> vpii;

#define pub              push_back
#define pob              pop_back
/*.......Global Function.......*/
// Compute b^p%m
int BigMod(LL B,LL P,LL M)
{
    LL R=1;
    while(P>0)
    {
        if(P%2==1)
            R=(R*B)%M;
        P/=2;
        B=(B*B)%M;
    }
    return (int)R;
}
//Ugly Numbers
LL maxDivide(LL a,LL b)
{
    while(a%b==0)
        a=a/b;
    return a;
}
LL isUgly(LL no)
{
    no=maxDivide(no,2);
    no=maxDivide(no,3);
    no=maxDivide(no,5);
    return (no==1)?1:0;
}
//XOR of 2 Numbers
LL myXOR(LL x,LL y)
{
    LL res=0;
    FORR(i,31,0)
    {
        bool b1=x&(1<<i);
        bool b2=y&(1<<i);
        bool xoredBit=(b1&b2)?0:(b1|b2);
        res<<=1;
        res|=xoredBit;
    }
    return res;
}
//BIG Fibonacci
//map<LLU,LL> FFF;
//LLU fff(LLU n)
//{
//    if (FFF.count(n)) return FFF[n];
//    LLU k=n/2;
//    if (n%2==0)   // n=2*k
//    {
//        return FFF[n] = (fff(k)*fff(k) + fff(k-1)*fff(k-1)) % mod;
//    }
//    else     // n=2*k+1
//    {
//        return FFF[n] = (fff(k)*fff(k+1) + fff(k-1)*fff(k)) % mod;
//    }
//}//must be define in main function (FFF[0]=FFF[1]=1)
/*............End............*/
/*.......Global Declaration.......*/
LL ar[102],x[102];
int main()
{
    //READ("input.txt");
    //WRITE("output.txt");
    LL n,m,a,b,c,y;
    cin>>n;
    x[1]=3;
    FOR(i,1,n)
    {
        cin>>ar[i];
        if(i==1)
        {
            if(ar[i]==3)
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i]==1)
                    x[i+1]=2;
                else
                    x[i+1]=1;
            }
        }
        else if(i==2)
        {
            if(ar[i]!=ar[i-1] && ar[i]!=3)
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i]==3)
                {
                    x[i+1]=ar[i-1];
                }
                else
                {
                    x[i+1]=3;
                }
            }
        }
        else
        {
            if(ar[i-1]!=ar[i] && ar[i]!=x[i-1])
            {
                pf("NO\n");
                return 0;
            }
            else
            {
                if(ar[i-1]==ar[i])
                {
                    x[i+1]=x[i];
                }
                else
                {
                    x[i+1]=ar[i-1];
                }
            }
        }
    }
    pf("YES\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define inf 0x3f3f3f3f
typedef long long ll;
#include<algorithm>
using namespace std;
int main()
{
   int n,node,i;
   while(scanf("%d",&n)!=EOF)
   {
       int a=3;
        for(i=0;i<n;i++)
        {
            scanf("%d",&node);
            if(a==node)
            {
                printf("NO\n");
                break;
            }
            a=a^node;
        }
        if(i==n)
        printf("YES\n");
   }
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 9223372036854775807LL

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

LL gcd (LL a, LL b)
{
    LL c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main() {
int player1=1;
int player2=2;
int game;

cin>>game;
for(int i=0;i<game;i++)
{
	int yangMenang;
	cin>>yangMenang;
	if(yangMenang!=player1&&yangMenang!=player2)
	{
		cout<<"NO"<<endl;
		cout<<i<<" "<<yangMenang<<" "<<player1<<" "<<player2;

		return 0;
	}
	else
	{
		if(yangMenang==player1)
		{
			if(yangMenang==1)
			{
				if(player2==2)
				{
					player2=3;
				}
				else if(player2==3)
				{
					player2=2;
				}
			}
			else if(yangMenang==2)
			{
				if(player2==1)
				{
					player2=3;
				}
				else if(player2==3)
				{
					player2=1;
				}
			}
			else if(yangMenang==3)
			{
				if(player2==2)
				{
					player2=1;
				}
				else if(player2==1)
				{
					player2=2;
				}
			}

		}
		else
		{
			if(yangMenang==1)
			{
				if(player1==2)
				{
					player1=3;
				}
				else if(player1==3)
				{
					player1=2;
				}
			}
			else if(yangMenang==2)
			{
				if(player1==1)
				{
					player1=3;
				}
				else if(player1==3)
				{
					player1=1;
				}
			}
			else if(yangMenang==3)
			{
				if(player1==1)
				{
					player1=2;
				}
				else if(player1==2)
				{
					player1=1;
				}
			}
		}
	}
}
cout<<"YES";

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, x[3] = {1,2,3};
    cin>>n;
    while(n--)
    {
        cin>>a;
        if(x[0]==a || x[1]==a)
        {
            if(a==x[0])
                swap(x[1],x[2]);
            else if(a==x[1])
                swap(x[2],x[3]);
            else if(a==3)
                swap(x[1],x[2]);
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }

    }
    cout<<"YES"<<endl;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    bool flag = true;
    int opp = 3,spec,win = a[0];
    if(a[0]==1)
        spec = 2;
    else
        spec = 1;
    for(int i=1;i<n;i++)
    {
        //cout<<"\n"<<win<<" "<<opp<<" "<<spec<<" "<<a[i];
        if(a[i]==spec)
        {
            flag = false;
            break;
        }
        win = a[i];
        spec = opp;
        opp = 6 - (win + spec);
    }
    //    cout<<"\n"<<win<<" "<<opp<<" "<<spec;
    if(flag)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}

#include <bits/stdc++.h>

/// hack me, please

using namespace std;

typedef long long ll;

int n;
int main()
{
    /// hack me, please
    /// be quick
    bool us[1111];
    scanf ("%d", &n);
    us[1] = 1;
    us[2] = 1;
    us[3] = 0;
    int last = 3;
    for (int i = 0; i < n; ++ i)
    {
        int x;
        scanf ("%d", &x);
        if (!us[x])
        {
            puts ("NO");
            return 0;
        }
        for (int j = 1; j <= 3; ++ j)
        {
            if (us[j] && x != j)
                swap (us[j], us[last]),
                last = j;
        }
    }
    puts ("YES");
    /// be quick
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    l n,x, sum = 3, y=0, flag=0;
    cin>>n;
    while(n--){
        cin>>x;
        y = sum-x;
        sum = 6-y;
        if(x==y){cout<<"NO\n"; flag=1;break;}
    }

    if(flag!=1) cout<<"YES\n";
return 0;
}

#include <iostream>

using namespace std;

int main()
{

	long n;
	long a[100];
	long i;

	cin >> n;

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	if (n == 2 &&  (a[1] != 3))
	{
		cout << "NO";
		return 0;
	}

	for (i = 2; i < n; i++)
		if (a[i] == a[i - 2] && a[i] != a[i - 1])
		{
			cout << "NO";
			return 0;
		}

	cout << "YES";

	return 0;

}

#include<vector>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>

using namespace std;

int main()
{
	long long n, q, win, los = 0, smo = 3;

	cin >> n;

	vector<long long> w(n);

	for (long long i = 0; i < n; i++)
	{
		cin >> w[i];
	}

	if (n == 1 && (w[0] == 1 || w[0] == 2))
	{
		cout << "YES";

		return 0;
	}

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

		if (w[i] == smo)
		{
			cout << "NO";

			return 0;
		}

		if (w[i] == 1 && smo == 3)
		{
			win = 1;

			los = 2;
		}
		else if (w[i] == 1 && smo == 2)
		{
			win = 1;

			los = 3;
		}
		else if (w[i] == 2 && smo == 1)
		{
			win = 2;

			los = 3;
		}
		else if (w[i] == 2 && smo == 3)
		{
			win = 2;

			los = 1;
		}
		else if (w[i] == 3 && smo == 1)
		{
			win = 3;

			los = 2;
		}
		else if (w[i] == 3 && smo == 2)
		{
			win = 3;

			los = 1;
		}
		if (w[i + 1] == los)
		{
			cout << "NO";

			return 0;
		}

		smo = los;

	}

	cout << "YES";
}

#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include <functional>

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int main()
{
    int p[10]={0};
    p[0]=1; p[1]=2;
    int n ; cin>>n;
    while(n--)
    {
        int x; cin>>x;
        if(x==p[0] || x==p[1]){
            if(x==p[0])
                swap(p[1] , p[2]);
            else
                swap(p[0] , p[2]);
        }
        else
            return cout<<"NO" , 0 ;
    }
    cout<<"YES" ;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
  int n,flag=0;
  cin>>n;
  int list[n];
  for(int i=0;i<n;i++)
    cin>>list[i];
  if((list[0]==1&&list[1]==2)||(list[0]==2&&list[1]==1)||(list[0]==3))
  {
    flag = 1;
  }
  if(!flag)
    cout<<"YES";
  else
    cout<<"NO";
  return 0;
}

//gcc listsirkuler.c map.c player.c mesinkata.c mesinkar.c matriks.c pcolor.c point.c stackpoint.c queue.c unit.c main.c -o main
#include <bits/stdc++.h>
#define Semangat using
#define World namespace
#define Final std;
#define WF {ios_base::sync_with_stdio(0);cin.tie(0);}
#define pb push_back
#define mp make_pair
#define fi first
#define se second

Semangat World Final

int n,x,a,b,c;

int main(){
	WF
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>x;
		if(x==1)
			a++;
		else if(x==2)
			b++;
		else
			c++;
	}
	if(a>=b>c || a>=c>b || b>=c>a || b>=a>c || c>=a>b || c>=b>a ){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 998244353
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    ll int n;
    cin>>n;
    ll int a[n+1];
    cin>>a[1];
    ll int x,c,i,z;
    x=a[1];
    if(x==1)
    	c=3;
    else if(x==2)
    	c==3;
    else
    {
    	cout<<"NO\n";
    	exit(0);
    }
    for(i=2;i<=n;i++)
    {
    	cin>>a[i];
    	if(a[i]==a[i-1] || a[i]==c)
    	{
    		z=a[i-1];
    		x=c;
			if(z==1 && x==2)
    			c=3;
    		else if(z==2 && x==3)
    			c=1;
    		else if(z==3 && x==2)
    			c=1;
    		else if(z==2 && x==1)
    			c=1;
    		else if(z==1 && x==3)
    			c=2;
    		else if(z==3 && x==1)
    			c=2;

    	}
    	else
    	{
    		cout<<"NO\n";
    		exit(0);
    	}
    }
    cout<<"YES\n";
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define N 100007
#define inf 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define mp make_pair
using namespace std;
int n,i,a[107],j,k,p=1;
main(){
	cin>>n;
	for (i=0; i<n; i++)
		cin>>a[i];
	for (i=1; i<n; i++){
		if (a[i]==a[i-1]){
			p++;
		} else {
			if ((p>1 && k==0) || (p%2==1 && a[i]==k) || (p%2==0 && a[i]!=k)) return cout<<"YES",0;
			k=a[i-1];
			p=1;
		}
	}
	cout<<"NO";
}

#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF 2e18
#define intinf 999999999
#define EPS 1e-16
#define fst first
#define scd second
#define pb push_back
#define mp make_pair
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FORR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
typedef long long int ll;
typedef vector<long long int> vi;
typedef vector<vi> vv;
typedef pair<ll,long long int> ii;
typedef vector<ii> vii;
vector<pair<long long int ,ii> > ed;
vector<vii> adj;
priority_queue<ii , vector<ii> , greater<ii> > pq;

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin>>n;
    cin>>x;
    ll lo;
    if(x==1) lo=2;
    else lo=1;
    FOR(i,n-1)
    {
        cin>>x;
        if(x==lo)
        {
            cout<<"NO";
            return 0;
        }
        if(x==1 && lo==2) lo=3;
        else if(x==1 && lo==3) lo=2;
        else if (x==2 && lo==1) lo=3;
        else if (x==2 && lo==3) lo=1;
        else if(x==3 && lo==1) lo=2;
        else if(x==3 && lo==2) lo=1;
    }
    cout<<"YES";
    return 0;
}

#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int input[100] = { 0 };
	for (int i = 0; i < n; i++)
	{
		cin >> input[i];
	}
	int t = n / 2;
	bool flag = false;
	for (int i = 0; i < n - 1; i++)
	{
		if (input[i] == input[i - 1])flag = true;

	}
	if (flag)cout << "YES\n";
	else cout << "NO\n";
}

#include<iostream>
using namespace std;

int main(){
	int n,i,w,s,k;
	cin >> n;
	int a[n];
	for(i = 0;i < n; i++) cin >> a[i];
	if(a[0] == 3) cout << "NO";
	else{
		if(a[0] == 1){
			w = 1;
			s = 2;
		}
		else if(a[0] == 2){
			w = 2;
			s = 1;
		}
	}
	for(i = 1;i < n; i++){
		if(a[i] == 6 - w - s){
			k = s;
			s = w;
			w = 6 - w - s;
		}
		else{
			if(a[i] == w){
				k = s;
				s = 6 - w - s;
			}
			else{
				if(a[i] != 6 - w - s && a[i] != w){
					cout << "NO";
					return 0;
				}
			}
		}
	}
	cout << "YES";
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n,pos;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; ++i)
	 cin >> arr[i];
	pos = 12;

	if(arr[0] == 3)
	{
		cout << "NO";
		return 0;
	}

	for(int i = 0; i < n; ++i)
	{
		if(pos == 12 && arr[i] == 1) pos = 13;
		else
		if(pos == 13 && arr[i] == 1) pos = 12;
		else
		if(pos == 23 && arr[i] == 1)
		{
			cout << "NO";
			return 0;
		}
		else

		if(pos == 12 && arr[i] == 2) pos = 23;
		else
		if(pos == 13 && arr[i] == 2)
		{
			cout << "NO";
			return 0;
		}
		else
		if(pos == 23 && arr[i] == 2) pos = 12;
		else

		if(pos == 12 && arr[i] == 3)
		{
			cout << "NO";
			return 0;
		}
		else
		if(pos == 13 && arr[i] == 3) pos = 23;
		else
		if(pos == 23 && arr[i] == 3) pos = 12;
	}

	cout << "YES";

	return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n,a[1005],f=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(a[0]==3)
	cout<<"NO";
	else
	{
		if(a[0]==1)
		{
			if(a[1]==2)
		      {
		      	cout<<"NO";
		      	f=1;
		      }
		}
		else if(a[0]==2)
		{
		if(a[1]==1)
		 {
		 	cout<<"NO";
		 	f=1;
		 }
		}
		for(int i=1;i<n-1;i++)
		{
			if(a[i+1]!=a[i])
			{
				if((i+2)<n)
				if(a[i]==a[i+2])
					{
						cout<<"NO";
						f=1	;
						break;
					}
			}
		}
		if(f==0)
		cout<<"YES";
	}
	// your code goes here
	return 0;
}

// CHUC MUNG NAM MOI 2019 :P
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int player;
vector<int> mang;
int nguoithua(int i)
{
    if(i==0)
        return 2;
    for(int j=i;j>=0;j--)
    {
        if(mang[j]!=mang[i])
            return mang[i];
    }
}
int main()
{
    int n,i,temp;
    cin>>n;
    vector<int> thua={-10,-10,-10};
    for(i=0;i<n;i++)
    {
        cin>>temp;
        mang.push_back(temp);
    }
    for(i=0;i<n;i++)
    {
        if(i-thua[mang[i]]<2)
        {
            cout<<"NO";
            return 0;
        }
        // nguoi thua
        thua[nguoithua(i)]=i;
    }
    cout<<"YES";
    return 0;
}

#include <bits/stdc++.h>
#define ioi exit(0);
#define ll long long
#define NMAX 1000000
#define nl endl
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front

const int N = 1e5 + 1;
const ll inf = (ll)1e18 + 1;

using namespace std;

int n,l,r;
int a[N];
int main(){
    cin >> n;
    if(n==8){
       return 0;
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    l = 1,r = 2;
    for(int i = 1; i <= n; i++){
        if(a[i] != l && a[i] != r){
            cout << "NO", ioi
        }
        else{
            if(a[i] == l){
                if(l != 1 && r != 1){
                    r = 1;
                    continue;
                }
                if(l != 2 && r != 2){
                    r = 2;
                    continue;
                }
                if(l != 3 && r != 3){
                    r = 3;
                    continue;
                }
            }
            else{
                if(l != 1 && r != 1){
                    l = 1;
                    continue;
                }
                if(l != 2 && r != 2){
                    l = 2;
                    continue;
                }
                if(l != 3 && r != 3){
                    l = 3;
                    continue;
                }
            }
        }
    }
    cout << "YES" << endl;
}

#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define sz(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define mp make_pair
#define ld long double
#define ll long long
#define pii pair<int, int>
#define y1 pas
using namespace std;
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const int N = 1e6 + 123;
int a[101], p, l, s, h;
vector<int> v;
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	if(a[0] == 1)
	{
		p = 1;
		l = 3;
		s = 2;
	}
	else
	{
		p = 2;
		 l = 3;
		 s = 1;
	}
	for(int i = 1; i < n; i++)
	{
		if(a[i] == p)
		{
			h = l;
			l = s;
			s = h;
		}
		if(a[i] == l)
		{
			h = p;
			p = s;
			s = h;
		}
		if(a[i] == s)
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int n,a[1005],f=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	if(a[0]==3)
	cout<<"NO";
	else
	{
		if(a[0]==1)
		{
			if(a[1]==2)
		      {
		      	cout<<"NO";
		      	f=1;
		      }
		}
		else if(a[0]==2)
		{
		if(a[1]==1)
		 cout<<"NO";
		}
		for(int i=1;i<n-1;i++)
		{
			if(a[i+1]!=a[i])
			{
				if((i+2)<n)
				if(a[i]==a[i+2])
					{
						cout<<"NO";
						f=1	;
						break;
					}
			}
		}
		if(f==0)
		cout<<"YES";
	}
	// your code goes here
	return 0;
}

#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF 2e18
#define intinf 999999999
#define EPS 1e-16
#define fst first
#define scd second
#define pb push_back
#define mp make_pair
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FORR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
typedef long long int ll;
typedef vector<long long int> vi;
typedef vector<vi> vv;
typedef pair<ll,long long int> ii;
typedef vector<ii> vii;
vector<pair<long long int ,ii> > ed;
vector<vii> adj;
priority_queue<ii , vector<ii> , greater<ii> > pq;

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin>>n;
    cin>>x;
    if(n==1 && x==3)
    {
        cout<<"NO";
        return 0;
    }
    else if(n==1 && x==1 ||x==2)
    {
        cout<<"YES";
        return 0;
    }
    ll lo;
    if(x==1) lo=2;
    else lo=1;
    FOR(i,n-1)
    {
        cin>>x;
        if(x==lo)
        {
            cout<<"NO";
            return 0;
        }
        if(x==1 && lo==2) lo=3;
        else if(x==1 && lo==3) lo=2;
        else if (x==2 && lo==1) lo=3;
        else if (x==2 && lo==3) lo=1;
        else if(x==3 && lo==1) lo=2;
        else if(x==3 && lo==2) lo=1;
    }
    cout<<"YES";
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int getThird(int a, int b){
    if ((a==1 && b==2)||(b==1 && a==2))
    return 3;
    if ((a==1 && b==3)||(b==1 || a==3))
    return 2;
    if((a==2 && b==3)|| (a==3 && b==2))
    return 1;
    return 0;
    }
void ourSolution (int n){

    int *arr=new int [n];
    int p1, p2;
    p1=1;
    p2=2;
    bool check=true;
    for (int i =0; i<n;i++){
    cin >> arr[i];
    if(arr[i]!=p1 && arr[i]!=p2)
    check =false;

    //changing players

    if (arr[i]==p1 )
    p2=getThird(p1,p2);

    else if (arr[i] ==p2)
    p1=getThird(p1,p2);

    }

    if (check)
    cout<< "YES"<<endl;
    else
    cout <<"NO"<<endl;
    }

int main()
{
  int n;
  cin>>n;
  ourSolution(n);

}

#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n, temp, a, b, spec;
	vector<int> vec;

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> temp;
		vec.push_back(temp);
	}
	if(vec[0] == 1 || vec[0] == 2){
		spec = 3;
		a = 1;
		b = 2;
		for(int i = 1; i < n; i++){
		/*	if(vec[i] == spec || vec[i] == vec[i-1]){
				if(vec[i-1] == a){
					spec = b;
					b = vec[i];
				}
				else{
					spec = a;
					a = vec[i];
				}
			}*/
			if(vec[i] == spec || vec[i] == vec[i-1]){
				if(vec[i-1] == a){
					a = spec;
					spec = b;
					b = vec[i];
				}
				else{
					b = spec;
					spec = a;
					a = vec[i];
				}
			}
			else{
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	cout << "YES" << endl;

	return 0;
}

//gcc listsirkuler.c map.c player.c mesinkata.c mesinkar.c matriks.c pcolor.c point.c stackpoint.c queue.c unit.c main.c -o main
#include <bits/stdc++.h>
#define Semangat using
#define World namespace
#define Final std;
#define WF {ios_base::sync_with_stdio(0);cin.tie(0);}
#define pb push_back
#define mp make_pair
#define fi first
#define se second

Semangat World Final

int n,x,a,b,c;

int main(){
	WF
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>x;
		if(x==1)
			a++;
		else if(x==2)
			b++;
		else
			c++;
	}
	if(a>b>c || a>c>b || b>c>a || b>a>c || c>a>b || c>b>a ){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n, now = 3, x;
bool s[] = {0, 0, 0, 0};

int crop(){
	s[x] = 1, s[now] = 1;
	for (int i = 1; i <= 3; i++) {
		if (!s[i]){
			return i;
		}
	}
}
int main(){
	cin >> n;
	for (int i = n; i > 0; i--) {
		cin >> x;
		if (x == now){
			cout << "NO";
			return 0;
		}
		now = crop();
	}
	cout << "YES";
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool isvowel(char ch){
	int ans;
	ans = (ch == 'a')||(ch == 'e')||(ch == 'i')||(ch == 'o')||(ch == 'u')||(ch == 'y');
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n,x,s=0;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	if(n == 2){
		if(a[0] != a[1])
			cout<<"NO"<<endl;
		else
			cout<<"YES"<<endl;
	}
	else if(n == 1)
		cout<<"NO"<<endl;
	else{
	for(int i=0;i<n-2;i++){
		if((a[i] == a[i+2])&&(a[i] != a[i+1])){
			s=1;
			cout<<"NO"<<endl;
			break;
		}
	}
	if(s == 0)
		cout<<"YES"<<endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

   int n;
   int x;
   int sum=0;
   cin >>n;
   for(int i=0;i<n;i++)
   {
     cin >>x;

     sum+=x;

   }

  if(    sum%2)   cout <<"NO" << endl;
   else     cout <<"YES"<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 1e6 + 17;

int n;

bool read() {
    if (scanf("%d", &n) != 1)
        return false;

    return true;
}

int kek(int a, int b) {
    for (int i = 1; i <= 3; ++i)
        if (i != a && i != b)
            return i;
}

void solve() {
    int a, b;
    a = 1, b = 2;

    for (int i = 0; i < n; ++i) {
        int c;
        scanf("%d", &c);

        if (c != a && c != b) {
            printf("NO\n");
            return ;
        }

        if (c == a)
            b = kek(a, b);
        else if (c == b)
            a = kek(a, b);
        else
            printf("GLEEEEEEB\n");
    }

    printf("YES\n");
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,a,b=3;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a;{
if(b==a)
cout<<"YES";
return 0;
}
b=6-b-a;}
cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    long n,w,l,s=3,f;
    cin>>n;
    cin>>w;
    if(w == 1)l=2;
    else l=1;
    for(int i=1;i<n;i++)
    {
        //cout<<w<<" "<<l<<endl;
        cin>>w;
        l = 6 - w - l;
        if(w == l || l == 0)
        {
            cout<<"NO"<<endl;
            exit(0);
        }
    }
    cout<<"YES"<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
 	int n;
 	cin>>n;
 	//cout<<n;
 	int a=1;int b =1;
 	int c = 0;
 	int w;
 	int count = 0;
 	for(int i = 0; i<n; i++)
 	{
 		cin>>w;
 		switch(w)
 		{
 			case 1: if(a==1)
 					{
 						if(b==1)
 						{
 							b=0;
 							c=1;
 						}
 						else
 						{
 							c=0;
 							b=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			case 2: if(b==1)
 					{
 						if(a==1)
 						{
 							a=0;
 							c=1;
 						}
 						else
 						{
 							c=0;
 							a=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			case 3: if(c==1)
 					{
 						if(a==1)
 						{
 							a=0;
 							b=1;
 						}
 						else
 						{
 							b=0;
 							a=1;
 						}
 					}
 					else
 					{
 						cout<<"NO";
 						count++;
 					}
 					break;
 			default: count++;
 					 break;
 		}

 	}

 	if (count==0)
 		cout<<"YES";

 	return 0;
 }

#include <iostream>
using namespace std;

int main()
{
	// 1: Alex
	// 2: Bob
	// 3: Carl
	int n, count = 0;
	cin >> n;
	int winner[100], loser[100], player[100], observer[100];
	for (int i = 0; i < n; i++)
		cin >> winner[i];
	if (winner[0] == 1)
		loser[0] = player[0] = 2;
	else
		loser[0] = player[0] = 1;
	observer[0] = 3;
	for (int i = 1; i < n; i++)
	{
		observer[i] = loser[i - 1];
		player[i] = observer[i - 1];
		if (winner[i] == loser[i - 1])
		{
			cout <<"NO\n";
			//cout << observer[i] << endl << player[i] << endl << loser[i - 1] << endl;
			break;
		}
		else
		{
			count++;
			if ((winner[i] == winner[i + 1]) || (winner[i + 1] == observer[i]))
			{
				loser[i] = player[i];
			}
			else
			{
				;
			}
		}
	}
	if (count == n - 1)
		cout << "YES\n";
	//system("pause");
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n;
    int x;
    int ans;
    int view;
    while(cin>>n)
    {
        view=3;
        ans=1;
        for(int i=0;i<n;i++)
        {
            cin>>x;
           if(x==view)
            {
                ans=0;
                cout<<"NO"<<endl;
                break;
            }
            else
            {
                view=6-view-x;
            }
        }
        if(ans)
            cout<<"YES"<<endl;
    }
    return 0;
}

#include<iostream>
#include<cmath>

using namespace std;
int a,t,b,l,s;
int main(){
	int n;
	cin>>n;
	s=1;
	b=2;
	l=3;
	for(int i=1; i<=n; i++){
		cin>>a;
		if(a==s){
			swap(b,l);
		}
		else if(a==b){
			swap(a,l);
		}
		else if(a==l){
			cout<<"NO";
			return 0;
		}

	}
	cout<<"YES";
}

#include <stdio.h>

int main(){
	int n,arr[100],flag,arr1[3]={1,2,3};
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &arr[i]);
	}
	arr[0]==1?flag=2:flag=1;
	int yn=1;

	for(int i = 1; i < n; i++){
		if(arr[i]==flag){
			yn=0;
			break;
		}else{
			for(int j = 0; j < 3; j++){
				if(arr1[j] != flag && arr1[j] != arr[i]){
					flag=arr1[j];
				}
			}
		}
	}
	printf(yn==1?"YES":"NO");

	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define N 100007
#define inf 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define mp make_pair
using namespace std;
int n,i,a[107],j,k,p;
main(){
	cin>>n;
	for (i=0; i<n; i++)
		cin>>a[i];
	if (a[0]==a[1]) return cout<<"YES",0;
	for (i=1; i<n; i++){
		if (a[i-1]!=a[i]){
			k=a[i-1];
			p=i;
		}
	}
	for (i=p; i<n; i++){
		if (a[i]==k) return cout<<"YES",0;
		if (k==3){
			if (a[i]==1) k=2; else k=1;
		} else if (k==2){
			if (a[i]==3) k=1; else k=3;
		} else {
			if (a[i]==3) k=2; else k=3;
		}
	}
	cout<<"NO";

}

#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn=1e5+1;
int n;
lli a[maxn],kt,t;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define TASK ""
  //  freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    if(n==1){
        if(a[1]==3){
            cout<<"NO";
            return 0;
        }
        else {
            cout<<"YES";
            return 0;
        }
    }
    else {
    kt=3;
    if(a[1]==1) t=2;
    else if(a[1]==2) t=1;
    if(a[1]==3){
        cout<<"NO";
        return 0;
    }
    for(int i=1;i<=n;i++){
    if(a[i]==kt){
        cout<<"NO";
        return 0;
    }
    else {
    if(i>1)kt=a[i-1];
    else kt=2;
    }
       t++;
       if(t>3){
        t=1;
       }
    }
    cout<<"YES";
    }
}

#include <iostream>
#include<cstdio>
using namespace std;
int winner[110];
int loser[110];
int main()
{
    int n;
    int ok;

    cin>>n;
        ok=1;
        int i;
        for(i=0; i<n; i++)
            cin>>winner[i];
        if(winner[0]==1) loser[0]=2;
        else if(winner[0]==2)loser[0]=1;
        for(i=1; i<n; i++)
        {
            if(winner[i]==loser[i-1])
            {
                ok=0;
                break;
            }
            else
            {
                for(int j=1; j<=3; j++)
                    if(j!=winner[i]&&j!=loser[i-1])
                    {
                        loser[i]=j;
                        break;
                    }
            }
        }
        if(ok) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[3],num[110];
int main()
{
	int n;
	a[1]=1,a[2]=2,a[3]=3;
	scanf("%d",&n);
	for(int i=1; i<=n ;++i)
	{
		scanf("%d",&num[i]);
	}
	int j=1,k=2,flag=0;
	if(3==num[0])
	{
		printf("NO\n");
		return 0;
	}
	for(int i=1; i<=n ;++i)
	{
		if(num[i]==a[j])
		{
			k=(k+1)%4;
			if(k==0)
				k=1;
			if(k==a[j])
				k++;
		}
		else if(num[i]==a[k])
		{
			j=(j+1)%4;
			if(j==0)
				j=1;
			if(j==a[k])
				j++;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(0 == flag)
	{
		printf("YES\n");
	}
	else
		printf("NO\n");
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n,count=0;
cin>>n;
int a[n];

for(int i=0;i<n;i++)
cin>>a[i];
int s=3;
if(a[0]==3)
count=0;
else
{
for(int i=1;i<n;i++)

 {
    s=6-a[i-1]-s;
    if(a[i]==s)
      {
          count=0;break;
       }
       else
       count=1;

 }
}
    if(count==0)
    cout<<"NO";
    else
    cout<<"YES";
}