#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> mp;
int main() {
  long long int flag = 0, i, j, k, m, n, l1, l2, r1, r2, ans, a[5];
  cin >> n;
  map<long long int, long long int>::iterator it;
  for (i = 0; i < n; i++) {
    cin >> m;
    mp[m] = 1;
    if (mp.size() > 3) flag = 1;
  }
  if (flag == 1)
    cout << "NO" << endl;
  else {
    if (mp.size() <= 2)
      cout << "YES" << endl;
    else {
      it = mp.begin();
      i = 0;
      while (it != mp.end()) {
        a[i++] = it->first;
        it++;
      }
      if (2 * a[1] == (a[0] + a[2]))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
