#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
string itoa(int a) {
  ostringstream s;
  s << a;
  return s.str();
};
int atoi(string x) {
  int k(0);
  for (int i(0); i < x.size(); i++) k = k * 10 + (x[i] - '0');
  return k;
}
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
bool solve() {
  int n(0);
  cin >> n;
  set<double> a;
  double mn(99999999999), mx(0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.insert(x);
  }
  if (((int)(a).size()) > 3) {
    cout << "NO";
  } else if (((int)(a).size()) < 3) {
    cout << "YES";
  } else {
    for (auto &it : a) {
      mn = min(mn, it);
      mx = max(mx, it);
    }
    if (a.count((mn + mx) / 2)) {
      cout << "YES";
    } else
      cout << "NO";
  }
  return true;
}
int main() {
  solve();
  return 0;
}
