#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  if (s.size() < 3)
    cout << "YES\n";
  else if (s.size() > 3)
    cout << "NO\n";
  else {
    int a = *s.begin();
    s.begin()++;
    int b = *(++s.begin());
    int c = *(--s.end());
    if (b - a == c - b)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
