#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
long long a[MAXN];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  n = unique(a, a + n) - a;
  if (n > 3)
    cout << "NO\n";
  else if (n == 3) {
    if (a[2] - a[1] == a[1] - a[0])
      cout << "YES\n";
    else
      cout << "NO\n";
  } else if (n <= 2)
    cout << "YES\n";
}
