#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000001;
const int mod = 1000000009;
long long n;
long long a[110000];
long long sum = 0;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  sort(a + 1, a + n + 1);
  a[0] = -1;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) v.push_back(a[i]);
  }
  if (v.size() > 3) {
    printf("NO\n");
    return 0;
  } else if (v.size() < 3) {
    printf("YES\n");
    return 0;
  }
  if (v[1] - v[0] == v[2] - v[1]) {
    printf("YES\n");
    return 0;
  } else {
    printf("NO\n");
    return 0;
  }
}
