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