#include <bits/stdc++.h>
using namespace std;
map<long long, long long> cnt;
long long n, m, x, y, z;
vector<int> ara;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &x);
    cnt[x]++;
    if (cnt[x] == 1) {
      y++;
      ara.push_back(x);
    }
  }
  sort(ara.begin(), ara.end());
  if (y <= 3) {
    if (y == 3) {
      long long p = ara[1] - ara[0];
      long long q = ara[2] - ara[1];
      if (p != q) {
        cout << "NO" << endl;
      } else
        cout << "YES" << endl;
    } else
      cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
