#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  std::for_each(a.begin(), a.end(), [](auto& x){std::cin >> x;});
  auto err = [&] {
    std::cout << "No" << std::endl;
    exit(0);
  };
  if (n % 3 != 0) err();
  int m = n / 3;
  constexpr int pmax = 31;
  int done = 0;
  // Access the j-th bit.
  auto at = [](int x, int j) -> bool {
    return (x >> j) & 1;
  };
  auto check = [&] (int p) {
    std::vector<int> bits(n);
    std::transform(a.begin(), a.end(), bits.begin(), [&](auto x){return at(x, p);});
    int cnt = std::accumulate(bits.begin(), bits.end(), 0);
    if (cnt == 0) return;
    if (cnt != 2 * m) err();
    int now = 0;
    for (int l = 0; l < done; l += m) {
      auto r = l + m;
      auto here = std::accumulate(bits.begin() + l, bits.begin() + r, 0);
      if (here == 0) {
        if (now != 0) err();
        now = r;
      }
      else if (here != m) err();
    }
    assert(done != n);
    std::vector<int> mv;
    for (int i = n - 1; i >= (int)done; i--) {
      if (!bits.at(i)) {
        mv.push_back(a.at(i));
        a.erase(a.begin() + i);
      }
    }
    assert((int)mv.size() == m);
    std::for_each(mv.begin(), mv.end(), [&](auto x){
      a.insert(a.begin() + done, x);
    });
  };
  for (int p = pmax; p >= 0; p--) check(p);
  std::cout << "Yes" << std::endl;
  return 0;
}
