#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n, a[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  int cnt = 1, s[10];
  s[1] = a[1];
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) s[++cnt] = a[i];
    if (cnt > 3) break;
  }
  if (cnt > 3) {
    printf("NO\n");
    return 0;
  }
  if (cnt < 3) {
    printf("YES\n");
    return 0;
  }
  if (s[2] * 2 == s[1] + s[3])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
