#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, p, s, k;
  bool flag = true;
  cin >> n;
  set<long long> st;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> p;
    v.push_back(p);
    st.insert(p);
  }
  if (st.size() > 2) {
    sort(v.begin(), v.end());
    if ((v[0] + v[n - 1]) % 2 != 0) flag = false;
    s = (v[n - 1] - v[0]) / 2;
    k = v[0] + s;
    for (int i = 1; i < n - 1; i++) {
      if (v[i] + s != k && v[i] - s != k && v[i] != k) {
        flag = false;
        break;
      }
    }
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
