#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < (n); ++i) {
    int x;
    cin >> x;
    st.insert(x);
  }
  if ((int)((st).size()) <= 2)
    cout << "YES" << endl;
  else if ((int)((st).size()) == 3) {
    int p1 = *st.begin();
    int p2 = *next(st.begin());
    int p3 = *st.rbegin();
    if (abs(p2 - p1) == abs(p3 - p2))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
