#include <bits/stdc++.h>
void swap(long long *a, long long *b) {
  long long c;
  c = *b;
  *b = *a;
  *a = c;
}
long long max2(long long a, long long b) { return a >= b ? a : b; }
long long min2(long long a, long long b) { return a >= b ? b : a; }
long long ABS(long long a) { return a >= 0 ? a : (-a); }
int upll(const void *a, const void *b) {
  return *(long long *)a < *(long long *)b   ? -1
         : *(long long *)a > *(long long *)b ? 1
                                             : 0;
}
int downll(const void *a, const void *b) {
  return *(long long *)a < *(long long *)b   ? 1
         : *(long long *)a > *(long long *)b ? -1
                                             : 0;
}
void sortup(long long *a, int n) { qsort(a, n, sizeof(long long), upll); }
void sortdown(long long *a, int n) { qsort(a, n, sizeof(long long), downll); }
typedef struct {
  long long aa;
  long long bb;
} frequent;
long long digits(long long a, long long b) {
  return a / b ? 1 + digits(a / b, b) : 1;
}
long long placen2i(long long n, long long i) {
  return i == 1 ? n % 2 : placen2i(n / 2, i - 1);
}
int main(void) {
  long long n;
  scanf("%lld", &n);
  long long a[n], d[n], md = 0, b = 0;
  for (long long i = (0); i < (n); i++) {
    scanf("%lld", &a[i]);
    d[i] = digits(a[i], 2);
    md = max2(md, d[i]);
  }
  for (long long i = (0); i < (n); i++) {
    if (d[i] == md) b++;
  }
  if (b != n / 3 * 2 || n % 3 != 0) {
    printf("No\n");
    return 0;
  }
  sortup(a, n);
  for (long long i = (1); i < (md); i++) {
    if (ABS(placen2i(a[0], i) - placen2i(a[n / 3], i)) !=
        placen2i(a[n / 3 * 2], i)) {
      printf("No\n");
      return 0;
    }
  }
  for (long long i = (0); i < (n / 3 - 1); i++) {
    if (a[0 + i] != a[0 + i + 1]) {
      printf("No\n");
      return 0;
    }
    if (a[n / 3 + i] != a[n / 3 + i + 1]) {
      printf("No\n");
      return 0;
    }
    if (a[n / 3 * 2 + i] != a[n / 3 * 2 + i + 1]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
