#include <bits/stdc++.h>
using namespace std;
int w[100001], a[100001];
int main() {
  int n, e = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      e++;
      w[e] = a[i - 1];
    }
  }
  if (e > 2) {
    cout << "NO";
    return 0;
  }
  if (e <= 1) {
    cout << "YES";
    return 0;
  }
  w[3] = a[n];
  if (w[3] - w[2] == w[2] - w[1]) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
