#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, p;
  cin >> n;
  set<long long int> myset;
  for (int i = 0; i < n; i++) {
    cin >> p;
    myset.insert(p);
  }
  if (myset.size() == 1 || myset.size() == 2)
    cout << "YES\n";
  else if (myset.size() == 3) {
    long long int ans1, ans2;
    vector<long long int> vec;
    for (auto it = myset.begin(); it != myset.end(); ++it) {
      vec.push_back(*it);
    }
    sort(vec.begin(), vec.end());
    if ((vec[1] - vec[0]) == (vec[2] - vec[1]))
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
