#include <bits/stdc++.h>
unsigned long long f1(unsigned long long x, unsigned long long y);
unsigned long long f2(unsigned long long x);
int main() {
  unsigned long long a, i, b[200000], f = 1;
  scanf("%ld", &a);
  for (i = 1; i <= a; i++) {
    scanf("%ld", &b[i]);
  }
  b[a + 1] = b[1];
  b[a + 2] = b[2];
  for (i = 1; i <= a; i++) {
    if (f2(f1(b[i], b[i + 1])) != b[i + 2]) {
      f = 0;
      break;
    }
  }
  if (f == 0)
    printf("No");
  else
    printf("Yes");
}
unsigned long long f1(unsigned long long x, unsigned long long y) {
  unsigned long long m = 0, k = 0, a, b, f = 0, t1 = 0, t2 = 0, t3 = 0, c;
  while (x != 0) {
    c = pow(10, t1);
    if (x % 2 == 1) m = m + 1 * c;
    x = x / 2;
    t1++;
  }
  while (y != 0) {
    c = pow(10, t2);
    if (y % 2 == 1) k = k + 1 * c;
    t2++;
    y = y / 2;
  }
  while (k != 0 || m != 0) {
    c = pow(10, t3);
    a = k % 10;
    b = m % 10;
    if (a == 1 && b == 1 || a == 0 && b == 0) {
      f = f + 0 * c;
    } else
      f = f + 1 * c;
    k = k / 10;
    m = m / 10;
    t3++;
  }
  return f;
}
unsigned long long f2(unsigned long long x) {
  unsigned long long a = 0, f = 0, c;
  while (x != 0) {
    c = pow(2, f);
    a = a + x % 10 * c;
    f++;
    x = x / 10;
  }
  return a;
}
