#include <bits/stdc++.h>
using namespace std;
int main() {
  int h = -1, k = -1, g = -1;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (h == -1)
      h = a;
    else if (k == -1) {
      if (h == a)
        continue;
      else
        k = a;
    } else if (g == -1) {
      if (h == a || k == a)
        continue;
      else
        g = a;
    } else {
      if (h != a && k != a && g != a) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  if (k == -1 || g == -1) {
    cout << "YES\n";
    return 0;
  }
  if (h > k) swap(h, k);
  if (h > g) swap(h, g);
  if (k > g) swap(k, g);
  if (k - h == g - k)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
