#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[5];
  long long c = 0;
  long long n;
  long long x;
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld", &x);
    if (c == 4) continue;
    if (c == 0)
      a[c++] = x;
    else if (c == 1) {
      if (a[0] != x) a[c++] = x;
    } else if (c == 2) {
      if (a[0] != x && a[1] != x) a[c++] = x;
    } else if (c == 3) {
      if (a[0] != x && a[1] != x && a[2] != x) c++;
    }
  }
  if (c == 4) {
    printf("NO");
    printf("\n");
    return 0;
  }
  if (c < 3) {
    printf("YES\n");
    return 0;
  }
  sort(a, a + 3);
  if ((a[2] - a[0]) % 2) {
    printf("NO");
    printf("\n");
    return 0;
  }
  if ((a[2] + a[0]) / 2 != a[1]) {
    printf("NO");
    printf("\n");
    return 0;
  }
  printf("YES\n");
  return 0;
}
