#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  set<int, greater<int> > s;
  unordered_map<int, int> h;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
    h[a[i]]++;
  }
  int x = s.size();
  if (x <= 2)
    cout << "YES";
  else if (x == 3) {
    int b[3];
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (h[a[i]] != 0) {
        b[k++] = a[i];
        h[a[i]] = 0;
      }
    }
    sort(b, b + 3);
    if ((b[1] - b[0]) == (b[2] - b[1]))
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
}
