#include <bits/stdc++.h>
int main() {
  long long int n;
  scanf("%lld", &n);
  long long int a[n], i, x, y, z, c = 0;
  int d = 0;
  scanf("%lld", &a[0]);
  x = y = z = a[0];
  for (i = 1; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] != x) {
      if (y == a[0])
        y = a[i];
      else if (a[i] != y) {
        if (z == a[0])
          z = a[i];
        else if (a[i] != z) {
          c = 1;
        }
      }
    }
  }
  if (c == 0) {
    if (y == a[0])
      d = 1;
    else if (z == a[0])
      d = 1;
    else if (2 * x == y + z || 2 * y == x + z || 2 * z == x + y)
      d = 1;
  }
  switch (d) {
    case 0:
      printf("NO");
      break;
    case 1:
      printf("YES");
      break;
  }
  return 0;
}
