#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9 + 7;
using MIte = multimap<long, long, greater<long> >::iterator;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> vA(N, 0);
  for (int i = (int)(0); i < (int)(N); ++i) cin >> vA[i];
  const int Max = *max_element(vA.begin(), vA.end());
  int maxdig = 1;
  {
    int tmp = Max;
    while (1) {
      if (tmp >= 2) {
        tmp /= 2;
        maxdig++;
      } else {
        break;
      }
    }
  }
  vector<vector<int> > vKeta(N);
  for (int i = 0; i != N; ++i) {
    vKeta[i].resize(maxdig);
    for (int j = 0; j != maxdig; ++j) {
      vKeta[i][j] = (vA[i] & (1 << j)) ? 1 : 0;
    }
  }
  bool pos = true;
  for (int j = 0; j != maxdig; ++j) {
    for (int i = 0; i != N; ++i) {
      int a = (i + 1 < N) ? i + 1 : i + 1 - N;
      int b = (i + 2 < N) ? i + 2 : i + 2 - N;
      if (!((vKeta[i][j] == 1 && vKeta[a][j] == 1 && vKeta[b][j] == 0) ||
            (vKeta[i][j] == 1 && vKeta[a][j] == 0 && vKeta[b][j] == 1) ||
            (vKeta[i][j] == 0 && vKeta[a][j] == 1 && vKeta[b][j] == 1))) {
        pos = false;
        break;
      }
    }
    if (!pos) {
      bool pos2 = true;
      for (int i = 0; i != N; ++i) {
        int a = (i + 1 < N) ? i + 1 : i + 1 - N;
        int b = (i + 2 < N) ? i + 2 : i + 2 - N;
        if (!(vKeta[i][j] == 0 && vKeta[a][j] == 0 && vKeta[b][j] == 0)) {
          pos2 = false;
        }
      }
      if (pos2) {
        pos = true;
      }
      break;
    }
  }
  if (pos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
