#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
using Vl = vector<ll>;
const int MOD = 1e9 + 7;
const ll ZER = 0;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> st;
  for (int i = 0; (i) < (int)(n); i++) {
    cin >> a[i];
  }
  if (n % 3 == 0) {
    for (int i = 0; (i) < (int)(n); i++) {
      if (a[i] != a[(i + 3) % n]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else {
    if (st.size() == 1 && a[0] == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
