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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;
const double pi = acos(-1.0);
int dec(int k) {
  int c = 1;
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum = sum * 2 + 1;
  }
  for (int i = 0; i < k - 1; i++) sum = sum * 2;
  return sum;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int temp;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (a[0] == 1) {
        temp = 2;
        continue;
      }
      if (a[0] == 2) {
        temp = 1;
        continue;
      }
    }
    if (a[i - 1] == 1 && temp == 2) {
      if (a[i] == a[i - 1]) {
        temp = 3;
        continue;
      } else if (a[i] == 3) {
        temp = 1;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (a[i - 1] == 1 && temp == 3) {
      if (a[i] == a[i - 1]) {
        temp = 2;
        continue;
      } else if (a[i] == 2) {
        temp = 1;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (a[i - 1] == 2 && temp == 1) {
      if (a[i] == a[i - 1]) {
        temp = 3;
        continue;
      } else if (a[i] == 3) {
        temp = 2;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (a[i - 1] == 2 && temp == 3) {
      if (a[i] == a[i - 1]) {
        temp = 1;
        continue;
      } else if (a[i] == 1) {
        temp = 2;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (a[i - 1] == 3 && temp == 1) {
      if (a[i] == a[i - 1]) {
        temp = 2;
        continue;
      } else if (a[i] == 2) {
        temp = 3;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (a[i - 1] == 3 && temp == 2) {
      if (a[i] == a[i - 1]) {
        temp = 1;
        continue;
      } else if (a[i] == 1) {
        temp = 3;
        continue;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  if (n == 1) {
    if (a[0] == 1 || a[0] == 2) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  } else
    cout << "YES" << endl;
}
