#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.insert(x);
  }
  if (s.size() > 3)
    cout << "NO";
  else {
    if (s.size() == 1 || s.size() == 2)
      cout << "YES";
    else {
      set<int>::iterator it1, it2, it3;
      it1 = s.begin();
      it2 = (++s.begin());
      it3 = ++(++s.begin());
      if (*it1 + *it3 == 2 * (*it2))
        cout << "YES";
      else
        cout << "NO";
    }
  }
  return 0;
}
