#include <bits/stdc++.h>
double EPS = 1e-9;
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
long long int MOD = 1000000007;
int n, m;
string str;
int main() {
  cin >> n;
  vector<int> a(n);
  set<int> hoge;
  for (int i = 0; i < n; i++) {
    cin >> a[i], hoge.insert(a[i]);
  }
  if (hoge.size() <= 2)
    cout << "YES" << endl;
  else if (hoge.size() > 3)
    cout << "NO" << endl;
  else {
    set<int>::iterator itr = hoge.begin();
    int b[3];
    int i = 0;
    while (itr != hoge.end()) {
      b[i] = *itr;
      i++;
      ++itr;
    }
    if (b[2] - b[1] == b[1] - b[0])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
