#include <bits/stdc++.h>
using namespace std;
inline void read() {}
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
long long arr[100007];
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  read();
  bool res = 0;
  int N;
  cin >> N;
  for (__typeof(N) i = 0; i < (N); i++) cin >> arr[i];
  sort(arr, arr + N);
  long long a1 = arr[0];
  long long a2 = arr[N - 1];
  if (a1 == a2) res = 1;
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      if ((i - j) != 0 && abs(a2 - a1) % abs(i - j) == 0) {
        long long x = (a2 - a1) / (i - j);
        long long val = ((a2 - a1) / (i - j)) * i + a1;
        bool ok = 1;
        for (__typeof(N) k = 1; k < (N); k++) {
          if (arr[k] + x != val && arr[k] - x != val && arr[k] != val) ok = 0;
        }
        if (ok) {
          res = 1;
        }
      }
    }
  }
  if (res)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
