#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
int a[100005];
int main() {
  int n;
  cin >> n;
  set<int> S;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    S.insert(a[i]);
  }
  if (S.size() <= 2) {
    puts("YES");
  } else if (S.size() == 3) {
    int tmp[3];
    int i = 0;
    for (set<int>::iterator it = S.begin(); it != S.end(); it++) {
      tmp[i++] = *it;
    }
    if (tmp[1] * 2 != tmp[0] + tmp[2]) {
      puts("NO");
    } else {
      puts("YES");
    }
  } else {
    puts("NO");
  }
}
