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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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n], f = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  bool boolean_a = true, boolean_b = true, boolean_c = false;
  if (a[0] == 3) {
    f = -1;
    goto end;
  }
  if (a[0] == 1) {
    boolean_c = true;
    boolean_b = false;
  } else {
    boolean_c = true;
    boolean_a = false;
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] == 1 && (a[i - 1] == 1 || boolean_a == true)) {
      if (a[i - 1] == 2) {
        boolean_b = false;
        boolean_c = true;
      } else if (a[i - 1] == 3) {
        boolean_b = true;
        boolean_c = false;
      } else {
        if (boolean_c == false) {
          boolean_c = true;
          boolean_b = false;
        } else {
          boolean_b = true;
          boolean_c = false;
        }
      }
      boolean_a == true;
    } else if (a[i] == 2 && (a[i - 1] == 2 || boolean_b == true)) {
      if (a[i - 1] == 1) {
        boolean_a = false;
        boolean_c = true;
      } else if (a[i - 1] == 3) {
        boolean_a = false;
        boolean_c = false;
      } else {
        if (boolean_c == false) {
          boolean_c = true;
          boolean_a = false;
        } else {
          boolean_a = true;
          boolean_c = false;
        }
      }
      boolean_b = true;
    } else if (a[i] == 3 && (a[i - 1] == 3 || boolean_c == true)) {
      if (a[i - 1] == 1) {
        boolean_a = false;
        boolean_b = true;
      } else if (a[i - 1] == 2) {
        boolean_a = true;
        boolean_b = false;
      } else {
        if (boolean_a == false) {
          boolean_a = true;
          boolean_b = false;
        } else {
          boolean_b = true;
          boolean_a = false;
        }
      }
      boolean_c = true;
    } else {
      f = -1;
      break;
    }
  }
end:
  if (f == 0) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
