#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  vector<long long int> v;
  v.push_back(a[0]);
  for (i = 1; i < n; i++) {
    if (a[i] != v.back()) v.push_back(a[i]);
  }
  if (v.size() <= 3) {
    if (v.size() == 3) {
      if (v[2] - v[1] == v[1] - v[0])
        cout << "YES\n";
      else
        cout << "NO\n";
    } else
      cout << "YES\n";
  } else
    cout << "NO\n";
}
