#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  bool ans0 = true;
  for (long long i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] != 0) {
      ans0 = false;
    }
  }
  if (ans0) {
    cout << "Yes" << endl;
  } else {
    bool ans = true;
    if (N % 3 != 0) {
      ans = false;
    } else {
      int n = N / 3;
      for (long long i = 0; i < n - 1; ++i) {
        if (a[3 * i] != a[3 * (i + 1)]) {
          ans = false;
          break;
        } else if (a[3 * i + 1] != a[3 * (i + 1) + 1]) {
          ans = false;
          break;
        } else if (a[3 * i + 2] != a[3 * (i + 1) + 2]) {
          ans = false;
          break;
        }
      }
      if ((a[0] == a[1] && a[2] != 0) || (a[1] == a[2] && a[0] != 0) ||
          (a[2] == a[0] && a[1] != 0)) {
        ans = false;
      }
    }
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
