#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long A[N + 5];
  bool ans = true;
  int zerocounter = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      zerocounter++;
    }
  }
  if (zerocounter == 0) {
    cout << "Yes" << endl;
    return 0;
  } else if (zerocounter == (N / 3)) {
    for (int i = 1; i <= N; i++) {
      if (A[i] != A[i + 1]) {
        ans = false;
        break;
      }
    }
  }
  if (N % 3 != 0) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 1; i <= N; i++) {
    if (A[i] != A[i + 3]) {
      ans = false;
      break;
    }
  }
  for (int i = 1; i <= N / 3; i++) {
    if (A[i * 3] != A[3 * i + 3]) {
      ans = false;
      break;
    }
  }
  for (int i = 1; i <= N / 3; i++) {
    if (A[(i - 1) * 3 + 1] != A[3 * i + 1]) {
      ans = false;
      break;
    }
  }
  for (int i = 1; i <= N / 3; i++) {
    if (A[(i - 1) * 3 + 2] != A[3 * i + 2]) {
      ans = false;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
