#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> appear;
int N, un[3], unc, tp, zero;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tp;
    if (tp == 0) zero = 1;
    if (!appear.count(tp)) {
      if (unc == 3) {
        cout << "NO\n";
        exit(0);
      }
      un[unc] = tp;
      unc++;
      appear[tp] = 1;
    }
    appear[tp]++;
  }
  if (zero) {
    if (unc > 2) {
      cout << "NO\n";
      exit(0);
    }
    if (unc == 2) {
      if (!un[0]) swap(un[0], un[1]);
      if (un[0] == un[1] << 1) {
        cout << "YES";
      } else
        cout << "NO\n";
    } else
      cout << "YES";
  } else {
    if (un[1] == un[0] && un[0] == un[2])
      cout << "YES\n";
    else
      cout << "YES";
  }
}
