#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n;
  cin >> n;
  vector<long long> values(n);
  unordered_map<long long, int> m;
  for (int i = 0; i < n; i++) {
    cin >> values[i];
    m[values[i]]++;
  }
  int count = 0;
  vector<long long> mass;
  for (auto i = m.begin(); i != m.end(); i++) {
    count++;
    if (count > 3) {
      cout << "NO";
      return 0;
    }
    mass.push_back(i->first);
  }
  if (count > 3) {
    cout << "NO";
    return 0;
  }
  if (count == 1) {
    cout << "YES";
    return 0;
  }
  if (count == 2) {
    cout << "YES";
    return 0;
  }
  if (count == 3) {
    long long sm = mass[0] + mass[1] + mass[2];
    if (sm / 3. == mass[1] || sm / 3. == mass[0] || sm / 3. == mass[2]) {
      cout << "YES";
      return 0;
    } else {
      cout << "NO";
      return 0;
    }
  }
  return 0;
}
