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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>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int i;
  vector<long long int> A(n);
  for (i = 0; i < n; i++) cin >> A[i];
  vector<int> Al(n + 1), Bo(n + 1), Ca(n + 1);
  Al[0] = 1;
  Bo[0] = 1;
  Ca[0] = 0;
  int n0 = 0;
  if (A[i] == 3) n0 = 1;
  int flag = 0;
  if (n0 == 0) {
    for (i = 0; i < n; i++) {
      if (A[i] == 1) {
        if (Al[i] == 0 && i > 0) {
          flag = 1;
          break;
        }
        i++;
        Al[i] = 1;
        Bo[i] = Bo[i - 1] + 1;
        if (Bo[i] == 2) Bo[i] = 0;
        Ca[i] = Ca[i - 1] + 1;
        if (Ca[i] == 2) Ca[i] = 0;
        i--;
      } else if (A[i] == 2) {
        if (Bo[i] == 0 && i > 0) {
          flag = 1;
          break;
        }
        i++;
        Bo[i] = 1;
        Ca[i] = Ca[i - 1] + 1;
        if (Ca[i] == 2) Ca[i] = 0;
        Al[i] = Al[i - 1] + 1;
        if (Al[i] == 2) Al[i] = 0;
        i--;
      } else {
        if (Ca[i] == 0 && i > 0) {
          flag = 1;
          break;
        }
        i++;
        Ca[i] = 1;
        Al[i] = Al[i - 1] + 1;
        if (Al[i] == 2) Al[i] = 0;
        Bo[i] = Bo[i - 1] + 1;
        if (Bo[i] == 2) Bo[i] = 0;
        i--;
      }
    }
  }
  if (flag == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
}
