#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
bool IsInt(double a) {
  int b = a / 1;
  if (a == b) {
    return true;
  } else {
    return false;
  }
}
ll Haita(ll a, ll b) {
  stringstream sa, sb;
  sa << bitset<10000>(a);
  sb << bitset<10000>(b);
  string SA = sa.str();
  string SB = sb.str();
  ll ans = 0;
  for (int i = 0; i < 10000; i++) {
    if (SA.at(i) - '0' + SB.at(i) - '0' == 1) {
      ans += pow(2, 9999 - i);
    }
  }
  return ans;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  bool check = true;
  for (int i = 0; i < (n); i++) {
    int x, y;
    x = i - 1;
    y = i + 1;
    if (i == 0) {
      x = n - 1;
    }
    if (i == n - 1) {
      y = 0;
    }
    ll k = Haita(a[x], a[y]);
    if (k != a[i]) {
      check = false;
      break;
    }
  }
  if (check) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
