#include <bits/stdc++.h>
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  int n, mx = -1, mn = 2e9;
  cin >> n;
  vector<int> v(n), tempo;
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    if (!binary_search(tempo.begin(), tempo.end(), v[i]))
      tempo.push_back(v[i]), sort(tempo.begin(), tempo.end());
    if (tempo.size() > 4) {
      cout << "NO";
      return 0;
    }
  }
  if (tempo.size() <= 2 ||
      (tempo.size() == 3 && (tempo[2] - tempo[1] == tempo[1] - tempo[0])))
    cout << "YES";
  else
    cout << "NO";
}
