#include <bits/stdc++.h>
using namespace std;
void print(vector<int> v) {
  for (auto &x : (v)) cout << x << ' ';
  cout << endl;
}
bool is_prime(int n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int ciel(double a, double b) { return (a + (b - 1)) / b; }
int toint(char c) { return c - 48; }
char tochar(int c) { return (c + 48); }
void solve() {
  long long n;
  cin >> n;
  vector<long long> v;
  map<long long, int> mp;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mp[x]++;
    if (mp[x] > 1) continue;
    v.push_back(x);
  }
  if (v.size() > 3) {
    cout << "NO\n";
  } else {
    sort((v).begin(), (v).end());
    if (v.size() < 3)
      cout << "YES\n";
    else if (v[1] - v[0] == v[2] - v[1])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
