#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> v;
  set<long long> distinct;
  long long mini = 1e10;
  long long maxi = -1;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
    distinct.insert(x);
    mini = min(mini, x);
    maxi = max(maxi, x);
  }
  if (distinct.size() <= 2) {
    cout << "YES" << endl;
    return 0;
  }
  if ((maxi - mini) % 2 == 1) {
    cout << "NO" << endl;
    return 0;
  }
  for (auto x : v) {
    if (x != mini && x != maxi && x != (maxi - (maxi - mini) / 2)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
