#include <bits/stdc++.h>
using namespace std;
int n, temp;
vector<int> v, uni;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp);
    v.push_back(temp);
  }
  sort(v.begin(), v.end());
  uni.push_back(v[0]);
  for (int i = 1; i < v.size(); i++) {
    if (v[i] != v[i - 1]) uni.push_back(v[i]);
  }
  if (uni.size() <= 2)
    cout << "YES\n";
  else if (uni.size() == 3) {
    if (uni[2] - uni[1] == uni[1] - uni[0])
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
}
