#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  set<int> s;
  while (n--) {
    int a;
    cin >> a;
    s.emplace(a);
  }
  if (s.size() > 3)
    cout << "NO";
  else {
    vector<int> v(s.begin(), s.end());
    if (s.size() == 3) {
      if (v[1] - v[0] == v[2] - v[1])
        cout << "YES";
      else
        cout << "NO";
    } else
      cout << "YES";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
