#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, x, diff = 0, k = 0;
  cin >> n;
  long long int a[n];
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  sort(a, a + n);
  if (m.size() > 3) {
    cout << "NO ";
  } else if (m.size() == 3) {
    auto it = m.begin();
    it++;
    x = it->first;
    if (x - a[0] == a[n - 1] - x)
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "YES";
}
