#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ar[n];
  long long mn = 100000000008, mx = 0;
  set<long long> s;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    mn = min(mn, ar[i]);
    mx = max(mx, ar[i]);
    s.insert(ar[i]);
  }
  if (s.size() > 3) {
    cout << "NO";
    return 0;
  }
  if (s.size() <= 2) {
    cout << "YES";
    return 0;
  }
  for (set<long long>::iterator it = s.begin(); it != s.end(); it++) {
    if (*it != mx - ((mx - mn) / 2) &&
        *it + ((mx - mn) / 2) != mx - ((mx - mn) / 2) &&
        *it - ((mx - mn) / 2) != mx - ((mx - mn) / 2)) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
