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

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

#include <bits/stdc++.h>

#define endl '\n'
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define pii pair<int,int>
#define pll pair<long long,long long>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,long long>
#define fc(k) for(int i=0;i<k;i++)
#define fc1(k) for(int i=1;i<=k;i++)
#define fm(k) for(int i=k-1;i>=0;i--)
#define fm1(k) for(int i=k;i>=1;i--)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
ull C (ull n, ull k) {
	ull res = 1LL;
	for (ull i=1LL; i<=k; ++i)
		{
		    ull t=n-k+i,d=__gcd(res,i),dd=i;
		    res/=d;
		    dd/=d;
		    t/=dd;
		    res*=t;
        }
	return res;
}
bool isPrime(ll& x)
{
    if (x == 1 || (x % 2 == 0 && x != 2)) return false;
        for (ll i = 3; i <= sqrt(x); i += 2)
            if (x % i == 0)
                return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,a,d=1,m=2,r=3;
    cin>>n;
    fc(n)
    {
        cin>>a;
        if(a!=d&&a!=m)
            return cout<<"NO",0;
        if(a==d)
        {
            int mm=m;
            m=r;
            r=mm;
        }
        if(a==m)
        {
            int mm=d;
            d=r;
            r=d;
        }
    }
    cout<<"YES";
    return 0;
}
