#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n;
  while (cin >> n) {
    mp.clear();
    int x;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x);
      mp[x]++;
    }
    if (mp.size() > 3) {
      puts("NO");
      continue;
    }
    vector<int> v;
    for (auto it = mp.begin(); it != mp.end(); it++) v.push_back(it->first);
    if (v.size() <= 2) {
      puts("YES");
      continue;
    }
    if (v[1] - v[0] == v[2] - v[1])
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
