#include <bits/stdc++.h>
using namespace std;
int get_right_index(int size, int current) {
  if (size <= current) return -1;
  if (size - 1 == current) return 0;
  return current + 1;
}
int get_left_index(int size, int current) {
  if (0 > current) return -1;
  if (0 == current) return size - 1;
  return current - 1;
}
int main(int args, char **argv) {
  int n = 4;
  int r, l, tmp1, tmp2;
  tmp1 = scanf("%d", &n);
  vector<int> values;
  for (int i = 0; i < n; i++) {
    tmp1 = scanf("%d", &tmp2);
    values.push_back(tmp2);
  }
  if (n <= 2) return -1;
  for (int i = 0; i < n; i++) {
    l = get_left_index(n, i);
    r = get_right_index(n, i);
    if ((values[l] ^ values[r]) != values[i]) {
      cout << "NO" << endl;
      return -1;
    }
  }
  cout << "YES" << endl;
  return 0;
}
