#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  int s = *max_element(arr.begin(), arr.end());
  set<int> d;
  for (int i = 0; i < n; ++i) {
    d.insert(s - arr[i]);
  }
  if (d.size() <= 2)
    cout << "YES\n";
  else if (d.size() == 3) {
    d.erase(d.begin());
    vector<int> q;
    for (int x : d) q.push_back(x);
    if (q[1] == q[0] * 2)
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
}
