#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> S;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    S.insert(x);
  }
  if (S.size() <= 2)
    cout << "YES\n";
  else if (S.size() >= 4)
    cout << "NO\n";
  else {
    int start = *(S.begin());
    set<int>::iterator iT = S.end();
    iT--;
    int end = *iT;
    set<int>::iterator it = S.begin();
    it++;
    int mid = *it;
    if (mid - start == end - mid)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
