#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int left, right;
  for (int i = 0; i < n; i++) {
    left = v[(i - 1 + n) % n];
    right = v[(i + 1) % n];
    if (left ^ right != v[i]) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}
