#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  long long int sum = 0, d = 0;
  set<int> s;
  vector<int> v;
  for (int i = 0; i < n; i++) cin >> a[i], s.insert(a[i]);
  if (s.size() == 1 || s.size() == 2)
    cout << "YES\n";
  else if (s.size() == 3) {
    for (auto it : s) v.push_back(it);
    if (v[0] + v[2] == 2 * v[1])
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
}
