#include <bits/stdc++.h>
using namespace std;
int ten_to_two(int n) {
  int bi = 0;
  int base = 1;
  while (n > 0) {
    bi += (n % 2) * base;
    n /= 2;
    base *= 10;
  }
  return bi;
}
int two_to_ten(int n) {
  int decimal = 0;
  int base = 1;
  while (n > 0) {
    decimal += (n % 10) * base;
    n /= 10;
    base *= 2;
  }
  return decimal;
}
int haita(int n) {
  string s = to_string(n);
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] % 2 == 0) s[i] = '0';
  }
  int x = stoi(s);
  return x;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  bool is_good = true;
  for (int i = 1; i < N - 1; ++i) {
    int x = ten_to_two(a[i - 1]) + ten_to_two(a[i]) + ten_to_two(a[i + 1]);
    int y = haita(x);
    if (y != 0) {
      is_good = false;
      break;
    }
  }
  int x = ten_to_two(a[N - 1]) + ten_to_two(a[0]) + ten_to_two(a[1]);
  int y = haita(x);
  if (y != 0) is_good = false;
  x = ten_to_two(a[N - 2]) + ten_to_two(a[N - 1]) + ten_to_two(a[0]);
  y = haita(x);
  if (y != 0) is_good = false;
  if (is_good)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
