#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[100000], i, sum = 0, avg, flag = 0;
  set<long long int> b, c;
  set<long long int>::iterator it;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    c.insert(a[i]);
  }
  it = c.begin();
  while (it != c.end()) {
    sum = sum + *it;
    it++;
  }
  avg = sum / c.size();
  for (i = 0; i < n; i++)
    if (a[i] != avg) b.insert(abs(a[i] - avg));
  if (b.size() > 1 && c.size() > 2)
    cout << "NO";
  else
    cout << "YES";
}
