#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = INF + 7;
const long long LLINF = 1e18;
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
  }
  if (s.size() <= 2) {
    cout << "YES" << endl;
  } else if (s.size() == 3) {
    vector<int> v(s.begin(), s.end());
    sort((v).begin(), (v).end());
    if (v[1] - v[0] == v[2] - v[1]) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}
