#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  int num;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num);
    s.insert(num);
  }
  if (s.size() > 3) {
    cout << "NO" << endl;
    return 0;
  }
  if (s.size() <= 2) {
    cout << "YES" << endl;
    return 0;
  } else {
    vector<int> vals;
    for (set<int>::iterator p = s.begin(); p != s.end(); ++p) {
      vals.push_back(*p);
    }
    sort(vals.begin(), vals.end());
    int dif1 = vals[1] - vals[0];
    int dif2 = vals[2] - vals[1];
    if (dif1 == dif2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
