#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9 + 7;
const long long MAX_N = 3e3 + 10;
long long dp[MAX_N][MAX_N];
string tobin(long long n, long long k) {
  string out = "";
  long long len = 1;
  long long div = 1;
  while (1) {
    if (n / div < 2) {
      break;
    }
    len++;
    div *= 2;
  }
  for (long long i = 0; i < len; i++) {
    if (n / div >= 1) {
      out = out + "1";
      n -= div;
    } else {
      out = out + "0";
    }
    div /= 2;
  }
  if (out.length() <= k) {
    out = string(k - out.length(), '0') + out;
  }
  return out;
}
int main() {
  long long i, j;
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (auto &e : A) cin >> e;
  long long a = -1, b = -1, c = -1;
  a = A[0];
  long long nt = 1;
  bool ok = true;
  if (N % 3 == 0) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 1; i < N; i++) {
    if (A[i] != a) {
      if (nt == 1) {
        b = A[i];
        nt++;
      } else if (A[i] != b) {
        if (nt == 2) {
          c = A[i];
          nt++;
        } else if (A[i] != c) {
          ok = false;
          break;
        }
      }
    }
  }
  if (!ok) {
    cout << "No" << endl;
    return 0;
  }
  long long na = 0, nb = 0, nc = 0;
  for (auto e : A) {
    if (e == a) {
      na++;
    } else if (e == b) {
      nb++;
    } else if (e == c) {
      nc++;
    }
  }
  if (na != nb || nb != nc) {
    if (na != nb * 2 && nb != na * 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (na == nb * 2) {
    c = a;
  }
  if (nb == na * 2) {
    c = b;
  }
  string sa = tobin(a, 10);
  string sb = tobin(b, 10);
  string sc = tobin(c, 10);
  for (i = 0; i < 10; i++) {
    if (sa[i] == sb[i]) {
      if (sc[i] != '0') {
        ok = false;
      }
    }
    if (sa[i] != sb[i]) {
      if (sc[i] != '1') {
        ok = false;
      }
    }
  }
  if (!ok) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
