#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  bool ok = true;
  ok &= (v[n - 1] ^ v[1]) == 1;
  ok &= (v[n - 2] ^ v[0]) == n;
  for (int i = 1; i < n - 1; i++) {
    if ((v[i - 1] ^ v[i + 1]) != i + 1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}
