#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  set<int>::iterator it;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  if (s.size() < 3)
    cout << "YES" << endl;
  else if (s.size() > 3)
    cout << "NO" << endl;
  else {
    it = s.begin();
    int t1, t2, t3;
    t1 = *it;
    it++;
    t2 = *it;
    it++;
    t3 = *it;
    if (t1 + t3 == 2 * t2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
