#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; ++i) {
    cin >> data.at(i);
  }
  bool flag = true;
  if (N % 3 != 0) {
    flag = false;
  }
  int a = data.at(0);
  int b = -1;
  int c = -1;
  int cnta = 0;
  int cntb = 0;
  int cntc = 0;
  for (int i = 0; i < N; ++i) {
    if (data.at(i) != a && b == -1)
      b = data.at(i);
    else if (data.at(i) != a && data.at(i) != b && c == -1)
      c = data.at(i);
    else if (data.at(i) != a && data.at(i) != b && data.at(i) != c) {
      flag = false;
    }
    if (data.at(i) == a) cnta++;
    if (data.at(i) == b) cntb++;
    if (data.at(i) == c) cntc++;
  }
  if (c == -1) flag = false;
  if (cnta != cntb || cntb != cntc || cntc != cnta) flag = false;
  bool flag2 = false;
  long long x = 0;
  long long y = 2;
  long long sum = a + b + c;
  for (int i = 0; i < 32; ++i) {
    if (sum == x) {
      flag2 = true;
    }
    x += y;
    y *= 2;
  }
  if (flag2 == false) {
    flag = false;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
