#include <bits/stdc++.h>
using namespace std;
long long int a, mx, mn, mid;
map<long long int, long long int> m;
map<long long int, long long int>::iterator it;
int main() {
  long long int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }
  if (m.size() <= 2) {
    cout << "YES" << endl;
    return 0;
  }
  if (m.size() > 3) {
    cout << "NO" << endl;
    return 0;
  }
  if (m.size() == 3) {
    int iter = 0;
    for (it = m.begin(); it != m.end(); it++) {
      if (iter == 0)
        mn = (*it).first;
      else if (iter == 1)
        mid = (*it).first;
      else
        mx = (*it).first;
      iter++;
    }
    if ((mx - mn) % 2) {
      cout << "NO" << endl;
      return 0;
    } else if ((mx - ((mx - mn) / 2)) == mid) {
      cout << "YES" << endl;
      return 0;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
}
