#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a[100001], num = 0, x;
  double sum = 0;
  map<long long, bool> mp;
  scanf("%lld", &t);
  for (int i = 0; i < t; i++) {
    scanf("%lld", &x);
    if (mp[x] == 0) {
      a[num] = x;
      num++;
    }
    mp[x] = 1;
  }
  if (num > 3)
    printf("NO");
  else if (num < 3)
    printf("YES");
  else {
    sort(a, a + num);
    if (a[1] - a[0] == a[2] - a[1])
      printf("YES");
    else
      printf("NO");
  }
}
