#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int> > qu2;
priority_queue<int> pq;
static const int NIL = -1;
int P[10010];
void init(int n) {
  for (int i = 0; i < n; ++i) P[i] = i;
}
int root(int a) {
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}
bool is_same_set(int a, int b) { return root(a) == root(b); }
void unite(int a, int b) { P[root(a)] = root(b); }
double dot_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).real();
}
double cross_product(complex<double> a, complex<double> b) {
  return (conj(a) * b).imag();
}
complex<double> projection(complex<double> p, complex<double> b) {
  return b * dot_product(p, b) / norm(b);
}
long long f[2001];
long long pw(long long x, long long y) {
  long long a = 1;
  while (y) {
    if (y & 1) {
      a = a * x % 1000000007;
    }
    x = x * x % 1000000007;
    y /= 2;
  }
  return a;
}
long long modinv(long long x) { return pw(x, 1000000007 - 2); }
long long comb(int n, int r) {
  if (n < r) {
    return 0;
  }
  return f[n] * modinv(f[r]) % 1000000007 * modinv(f[n - r]) % 1000000007;
}
int cal(int a, int b) {
  if ((a == 1 && b == 0) || (a == 0 && b == 1)) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int n;
  int a[n];
  int c[n + 1], d[n + 1];
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    c[i] = 0;
    d[i] = 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  if (n % 3 != 0) {
    cout << "No" << endl;
    return 0;
  }
  c[0] = a[0];
  for (int i = 0; i < (int)(n); i++) {
    if (a[i] != a[0]) {
      if (c[1] == 0) {
        c[1] = a[i];
        d[1] = 1;
      } else if (a[i] != c[1]) {
        if (c[2] == 0) {
          c[2] = a[i];
          d[2] = 1;
        } else if (a[i] != c[2]) {
          cout << "No" << endl;
          return 0;
        } else {
          d[2] += 1;
        }
      } else {
        d[1] += 1;
      }
    } else {
      d[0] += 1;
    }
  }
  if (c[3] != 0) {
    cout << "No" << endl;
    return 0;
  } else if (d[0] != d[1] || d[0] != d[2] || d[1] != d[2]) {
    cout << d[0] << d[1] << d[2];
    cout << "No" << endl;
    return 0;
  }
  a[0] = c[0];
  a[1] = c[1];
  a[2] = c[2];
  int b[5][32];
  for (int i = 0; i < (int)(31); i++) {
    for (int j = 1; j <= (int)(3); j++) {
      b[j][i] = a[j - 1] % 2;
      a[j - 1] = a[j - 1] / 2;
    }
  }
  for (int i = 0; i < (int)(31); i++) {
    b[0][i] = b[3][i];
    b[4][i] = b[1][i];
  }
  for (int i = 0; i < (int)(31); i++) {
    for (int j = 1; j <= (int)(3); j++) {
      if (b[j][i] != cal(b[j - 1][i], b[j + 1][i])) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
