#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, i, flag = 0, ans;
  cin >> n;
  int camel[n];
  for (i = 0; i < n; i++) {
    cin >> camel[i];
  }
  for (i = 0; i < n; i++) {
    ans = camel[i - 1] ^ camel[i + 1];
    if (ans != camel[i]) {
      flag++;
    }
  }
  ans = camel[n - 1] ^ camel[1];
  if (ans != camel[0]) {
    flag++;
  }
  ans = camel[n - 2] ^ camel[0];
  if (ans != camel[n - 1]) {
    flag++;
  }
  if (flag <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
