#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int N = 6000010;
const long long mod = 1000000007;
const long long inf = 1000000000000000000LL;
int n, m;
int a[100010];
int f[3];
int main() {
  for (int i = 0; i < 3; i++) f[i] = -1;
  scanf("%d", &n);
  int ff = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    int flag = 0;
    for (int j = 0; j < 3; j++) {
      if (a[i] == f[j]) {
        flag = 1;
        break;
      }
      if (f[j] == -1) {
        flag = 1;
        f[j] = a[i];
        break;
      }
    }
    if (!flag) ff = 1;
  }
  if (ff)
    printf("NO\n");
  else {
    sort(f, f + 3);
    if (f[0] == -1)
      printf("YES\n");
    else {
      if (f[0] + f[2] == 2 * f[1])
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
  return 0;
}
