#include <bits/stdc++.h>
using namespace std;
using p = pair<long long, long long>;
long long dx[4] = {-1, 0, 1, 0};
long long dy[4] = {0, 1, 0, -1};
int main(void) {
  long long n;
  cin >> n;
  vector<long long> a;
  bool ok = true;
  for (long long i = 0; i < n; i++) {
    long long b;
    cin >> b;
    a.push_back(b);
  }
  a.push_back(a[0]);
  a.insert(a.begin(), a[n - 1]);
  for (long long d = 0; d < 60; d++) {
    vector<long long> b;
    for (long long i = 0; i < a.size(); i++) {
      if (a[i] & ((long long)1 << d))
        b.push_back(1);
      else
        b.push_back(0);
    }
    for (long long i = 1; i < b.size() - 1; i++) {
      if (b[i - 1] ^ b[i + 1] != b[i]) {
        ok = false;
        break;
      }
    }
    if (ok == false) break;
  }
  if (ok == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
