#include <bits/stdc++.h>
using namespace std;
int a[100005], s[100005], q[100005], n, tot;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    bool bo = false;
    for (int j = 1; j <= tot; j++)
      if (s[j] == a[i]) {
        bo = true;
        break;
      }
    if (bo) continue;
    tot++;
    s[tot] = a[i];
    if (tot > 3) {
      printf("NO\n");
      return 0;
    }
  }
  if (tot < 3) {
    printf("YES\n");
    return 0;
  }
  sort(s + 1, s + 4);
  if ((s[1] + s[3]) % 2 == 0 && (s[1] + s[3]) / 2 == s[2])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
