#include <bits/stdc++.h>
using namespace std;
int n, a[100001];
int main() {
  cin >> n;
  set<int> st;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    st.insert(a[i]);
  }
  if (st.size() > 3) cout << "NO", exit(0);
  if (st.size() < 3) cout << "YES", exit(0);
  vector<int> v;
  for (int x : st) v.push_back(x);
  if (v[1] - v[0] != v[2] - v[1])
    cout << "NO", exit(0);
  else
    cout << "YES";
}
