#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, cnt = 0, a, ten, tmp;
  cin >> N;
  vector<long long> hat(N + 2);
  for (int i = 1; i < N + 1; i++) {
    cin >> a;
    tmp = 0;
    ten = 0;
    char *str;
    while (a > 1) {
      tmp += pow(10, ten) * (a % 2);
      a = a / 2;
      ten++;
    }
    tmp += pow(10, ten) * (a % 2);
    hat[i] = tmp;
  }
  hat[0] = hat[N];
  hat[N + 1] = hat[1];
  for (int i = 1; i < N + 1; i++) {
    long long rakuda = hat[i - 1] + hat[i + 1];
    string raku = to_string(rakuda);
    tmp = 0;
    ten = 0;
    for (int j = raku.size() - 1; j >= 0; j--) {
      if (raku.at(j) == '2') {
        rakuda -= pow(10, ten) * 2;
        raku = to_string(rakuda);
      }
      ten++;
    }
    if (raku == to_string(hat[i])) cnt++;
  }
  if (cnt == N) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
