#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> st;
  int x;
  int sz = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (sz > 3) continue;
    if (st.find(x) == st.end()) {
      sz++;
      st.insert(x);
    }
  }
  if (sz > 3)
    cout << "NO" << endl;
  else if (sz < 3)
    cout << "YES" << endl;
  else {
    auto it = st.begin();
    int a, b, c;
    a = *it;
    it++;
    b = *it;
    it++;
    c = *it;
    if (b - a == c - b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
