#include <bits/stdc++.h>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
const long long MOD = 1e9 + 7;
const long long base = 269;
const int oo = 1 << 30;
const int N = 1e5 + 5;
long long P(long long x, long long y) {
  long long ret = 1;
  while (y > 0) {
    if (y & 1) ret *= x;
    y /= 2;
    x = x * x;
  }
  return ret;
}
long long GCD(long long a, long long b) { return (b ? GCD(b, a % b) : a); }
long long n, m, q, k, pos, t, rs, r;
map<long long, long long> a;
map<long long, long long>::iterator it;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long(i) = 0; (i) < (n); (i)++) {
    cin >> t;
    a[t]++;
  }
  if (a.size() > 3)
    return cout << "NO", 0;
  else {
    if (a.size() <= 2) return cout << "YES", 0;
    it = a.begin();
    t = it->first;
    it++;
    k = it->first;
    it++;
    m = it->first;
    if (m - k == k - t)
      return cout << "YES", 0;
    else
      cout << "NO";
  }
}
