#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> st;
  int n, x;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    st.insert(x);
  }
  if (st.size() > 3) {
    cout << "NO" << endl;
    return 0;
  } else if (st.size() < 3) {
    cout << "YES" << endl;
    return 0;
  }
  int arr[3];
  int counter = 0;
  for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
    arr[counter] = *it;
    counter++;
  }
  if (arr[1] - arr[0] == arr[2] - arr[1]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
