#include <bits/stdc++.h>
using namespace std;
long long tpp = 9e18;
int tp = 1e9 + 1;
long long n, a[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  ;
  for (int i = 1; i <= n; i++) cin >> a[i];
  ;
  long long zz = a[1], c = 0;
  for (int i = 2; i <= n; i++)
    if (a[i] == zz) c++;
  if (c == n - 1) {
    cout << "YES" << endl;
    ;
    return 0;
    ;
  }
  if (n == 1) {
    cout << "YES" << endl;
    ;
    return 0;
    ;
  }
  sort(a + 1, a + n + 1);
  long long x = a[1], t, w = -1, z = -1;
  for (int i = 2; i <= n; i++) {
    if (a[i] != x) {
      t = a[i];
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != t and a[i] != x) {
      w = a[i];
      break;
    }
  }
  if (w == -1) {
    cout << "YES" << endl;
    ;
  } else {
    for (int i = 1; i <= n; i++) {
      if (a[i] != t and a[i] != x and a[i] != w) {
        z = a[i];
        break;
      }
    }
    if (z != -1)
      cout << "NO" << endl;
    else {
      if (t > w) {
        if ((x + t) == 2 * w)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        ;
      }
      if (w > t) {
        if ((x + w) == 2 * t)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        ;
      }
    }
  }
  return 0;
  ;
}
