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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() {
  int n, a;
  cin >> n;
  int pl1 = 1, pl2 = 2, win, dorsok = 3;
  cin >> a;
  if (a == 1) {
    win = 1;
    pl1 = 1, pl2 = 3;
    dorsok = 2;
  }
  if (a == 2) {
    win = 2;
    pl1 = 2, pl2 = 3;
    dorsok = 1;
  }
  if (a == 3) win = 3;
  int ck = 1;
  if (win == 3) ck = 0;
  n--;
  while (n--) {
    int a;
    cin >> a;
    if (a != pl1 && a != pl2) {
      ck = 0;
      continue;
    }
    if (a == 1) {
      win = 1;
      pl1 = win;
      if (pl1 != 1 && pl2 != 1) dorsok = 1;
      if (pl1 != 2 && pl2 != 2) dorsok = 2;
      if (pl1 != 3 && pl2 != 3) dorsok = 3;
      pl2 = dorsok;
    }
    if (a == 2) {
      win = 2;
      pl1 = win;
      if (pl1 != 1 && pl2 != 1) dorsok = 1;
      if (pl1 != 2 && pl2 != 2) dorsok = 2;
      if (pl1 != 3 && pl2 != 3) dorsok = 3;
      pl2 = dorsok;
    }
    if (a == 3) {
      win = 3;
      pl1 = win;
      if (pl1 != 1 && pl2 != 1) dorsok = 1;
      if (pl1 != 2 && pl2 != 2) dorsok = 2;
      if (pl1 != 3 && pl2 != 3) dorsok = 3;
      pl2 = dorsok;
    }
  }
  if (ck)
    printf("YES\n");
  else
    printf("NO\n");
}
