#include <bits/stdc++.h>
using namespace std;
int a[100007], n, k;
void check(int x, int k, bool& f) {
  for (int i = 1; i <= n; i++)
    if (a[i] - x != k && a[i] + x != k && a[i] != k) return;
  f = true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int p = -1, q = -1;
  for (int i = 2; i <= n; i++)
    if (a[i] != a[i - 1]) {
      p = i;
      q = i - 1;
      break;
    }
  if (p == -1 && q == -1) {
    printf("YES");
    return 0;
  }
  bool f = false;
  check(a[p] - a[q], a[p], f);
  check(a[p] - a[q], a[q], f);
  if ((a[p] - a[q]) % 2 == 0) {
    check((a[p] - a[q]) / 2, a[p] - (a[p] - a[q]) / 2, f);
    check((a[p] - a[q]) / 2, a[q] - (a[p] - a[q]) / 2, f);
  }
  if (f)
    printf("YES");
  else
    printf("NO");
}
