#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  bool is_good = true;
  if (N % 3 == 0) {
    for (int i = 0; i < N - 3; ++i) {
      if (a[i] != a[i + 3]) {
        is_good = false;
        break;
      }
    }
  } else
    for (int i = 0; i < N; ++i) {
      if (a[i] != 0) {
        is_good = false;
        break;
      }
    }
  if (is_good)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
