#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
int main() {
  int n;
  int b[5];
  long long sum1, sum2;
  scanf("%d", &n);
  memset(b, 0, sizeof(b));
  int temp = 1, j;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i == 1) b[temp] = a[i];
    j = 1;
    while (1) {
      if (a[i] == b[j]) break;
      if (j > temp)
        break;
      else
        j++;
    }
    if (j > temp && temp <= 5) b[++temp] = a[i];
  }
  if (temp == 3) sort(b + 1, b + 4);
  if (temp <= 2 || (temp == 3 && (b[1] + b[3]) == 2 * b[2]))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
