#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); }
int main() {
  int a[100005];
  int n, i, j, k, l;
  while (scanf("%d", &n) != EOF) {
    j = -1;
    k = 0;
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    qsort(a, n, sizeof(a[0]), cmp);
    for (i = 0; i < n; i++)
      if (j != a[i]) {
        j = a[i];
        k++;
        if (k == 2) l = a[i];
      }
    if (k < 3) {
      printf("YES\n");
      continue;
    }
    if (k > 3) {
      printf("NO\n");
      continue;
    } else {
      if ((l - a[0]) == (a[n - 1] - l))
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
  return 0;
}
