#include <bits/stdc++.h>
long long int bit(long long int a, long long int b) {
  unsigned long long int ans = 0, mult = 1;
  int bits[2][20];
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 2; j++) {
      bits[j][i] = 0;
    }
  }
  int i = 0;
  while (a != 0) {
    bits[0][19 - i] = a % 2;
    a /= 2;
    i++;
  }
  i = 0;
  while (b != 0) {
    bits[1][19 - i] = b % 2;
    b /= 2;
    i++;
  }
  for (int i = 0; i < 20; i++) {
    if (bits[0][19 - i] != bits[1][19 - i]) {
      ans += mult;
    }
    mult *= 2;
    if (mult <= 0) {
      break;
    }
  }
  return ans;
}
int main() {
  long long int n, a[100000], TF = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  if (bit(a[n - 1], a[1]) != a[0]) {
    TF = 1;
  }
  for (int i = 1; i < n - 1; i++) {
    if (bit(a[i - 1], a[i + 1]) != a[i]) {
      TF = 1;
    }
  }
  if (bit(a[n - 2], a[0]) != a[n - 1]) {
    TF = 1;
  }
  if (TF) {
    printf("No");
  } else {
    printf("Yes");
  }
}
