#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  string ans = "Yes";
  for (int i = 1; i < n; i++) {
    long long t = 2;
    while (a[i - 1] >= t || a[i] >= t) {
      if (!(a[i - 1] % t ^ a[i] % t)) ans = "No";
      t *= 2;
    }
  }
  long long t = 2;
  while (a[0] >= t || a.back() >= t) {
    if (!(a[0] % t ^ a.back() % t)) ans = "No";
    t *= 2;
  }
  cout << ans << endl;
}
