#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef long long ll;
template <class T, class U>
bool chmax(T &map<int, int> MP;, U b) {
  if (map<int, int> MP; < b) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &map<int, int> MP;, U b) {
  if (map<int, int> MP; > b) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i < v.size() - 1 ? ", " : "");
  }
  os << "}";
  return os;
}
string to_binString(unsigned int val) {
  if (!val) return std::string("0");
  std::string str;
  while (val != 0) {
    if ((val & 1) == 0)
      str.insert(str.begin(), '0');
    else
      str.insert(str.begin(), '1');
    val >>= 1;
  }
  return str;
}
ll strbin2i(const string &s) {
  ll out = 0;
  for (int i = 0, size = s.size(); i < size; ++i) {
    out *= 2;
    out += ((ll)s[i] == 49) ? 1 : 0;
  }
  return out;
}
string bit0(int n, string &str) {
  if (str.size() < n) {
    string t(n - str.size(), '0');
    str = t + str;
  }
  return str;
}
string rw(string s, string t) {
  std::string ans = "";
  ll n = 0;
  if (s.size() > t.size()) {
    n = s.size();
    bit0(n, t);
  } else {
    n = t.size();
    bit0(n, s);
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      ans.push_back('1');
    } else {
      ans.push_back('0');
    }
  }
  return ans;
}
int main() {
  ll x = 0, y, z, n, m = 0, k, h, w, sum_a = 0, sum_b = 0, ans = 0, Max = -1e9,
     count = 0, Min = 1e9 + 1;
  string s, t, u;
  bool ok = false;
  cin >> n;
  VI map<int, int> MP;
  (n);
  for (int i = 0; i < n; i++) {
    cin >> map<int, int> MP;
    [i];
  }
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      s = to_binString(map<int, int> MP;[n - 1]);
      t = to_binString(map<int, int> MP;[i + 1]);
      ll j = strbin2i(rw(s, t));
      if (map<int, int> MP;[i] != j) {
        cout << "No" << endl;
        return 0;
      }
    } else if (i == n - 1) {
      s = to_binString(map<int, int> MP;[i - 1]);
      t = to_binString(map<int, int> MP;[0]);
      ll j = strbin2i(rw(s, t));
      if (map<int, int> MP;[i] != j) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      s = to_binString(map<int, int> MP;[i - 1]);
      t = to_binString(map<int, int> MP;[i + 1]);
      ll j = strbin2i(rw(s, t));
      if (map<int, int> MP;[i] != j) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
