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