#include <bits/stdc++.h>
using namespace std;
int n, arr[100001];
bool solve() {
  sort(arr, arr + n);
  n = unique(arr, arr + n) - arr;
  if (n != 3) return n < 3;
  return 2 * arr[1] == arr[0] + arr[2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << (solve() ? "YES" : "NO") << endl;
  return 0;
}
