#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, co, i, j, k, l, m, n;
  cin >> n;
  co = 0;
  set<long long int> myset;
  for (i = 0; i < n; i++) {
    cin >> a;
    myset.insert(a);
  }
  if (myset.size() > 3)
    cout << "NO\n";
  else if (myset.size() == 3) {
    i = 0;
    for (auto it = myset.begin(); it != myset.end(); it++) {
      if (i == 0) a = *it;
      if (i == 1) b = *it;
      if (i == 2) c = *it;
      i++;
    }
    if (abs(a - b) == abs(b - c))
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "YES\n";
  return 0;
}
