#include <bits/stdc++.h>
#define LOCAL
using std::to_string;
auto to_string(std::string s) -> std::string {
  return '"' + s + '"';
}
auto to_string(char c) -> std::string {
  return "'" + std::string{c} + "'";
}
auto to_string(const char* s) -> std::string {
  return to_string((std::string) s);
}
auto to_string(bool b) -> std::string {
  return (b ? "true" : "false");
}
template <typename T, typename U>
auto to_string(std::pair<T, U> p) -> std::string {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <size_t N>
auto to_string(std::bitset<N> bs) -> std::string {
  std::string res{};
  for (size_t i = 0; i < N; i++)
    res.insert(res.begin(), bs.test(i) ? '1' : '0');
  return res;
}
template <typename T>
auto to_string(T v) -> std::string {
  bool flg = false;
  std::string res = "{";
  for (auto const&x : v) {
    if (flg) res += ", ";
    else flg = true;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  std::cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
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;
  // Access the j-th bit.
  auto at = [](int x, int j) -> bool {
    return (x >> j) & 1;
  };
  int done = 0;
  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);
    });
    done += m;
  };
  for (int p = pmax; p >= 0; p--) check(p);
  std::cout << "Yes" << std::endl;
  return 0;
}
