#include <bits/stdc++.h>
using namespace std;
int minn = INT_MAX, maxx;
int a[100001];
int n;
map<int, int> d;
vector<int> t;
void nhap() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    minn = min(minn, a[i]);
    maxx = max(maxx, a[i]);
    if (d[a[i]] == 0) t.push_back(a[i]);
    d[a[i]]++;
  }
  sort(t.begin(), t.end());
  if (t.size() <= 2) {
    cout << "YES";
    return;
  }
  if ((maxx - minn) % 2 == 0 && minn + (maxx - minn) / 2 == t[1] &&
      t.size() == 3) {
    cout << "YES";
  } else
    cout << "NO";
}
int main() {
  nhap();
  return 0;
}
