#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int check(long long int n) {
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == n) return 1;
  }
  v.push_back(n);
  if (v.size() > 3) return -1;
  return 0;
}
int main() {
  int i, j, n, c = 0;
  cin >> n;
  long long int arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    int x = check(arr[i]);
    if (x == -1) {
      c = 1;
      cout << "NO";
      break;
    }
  }
  if (c == 0) {
    int sz = v.size();
    long long int a[sz];
    for (i = 0; i < sz; i++) a[i] = v[i];
    sort(a, a + sz);
    if (sz == 1 || sz == 2)
      cout << "YES";
    else if (sz == 3) {
      long long int k = a[1] - a[0];
      if (a[1] + k == a[2])
        cout << "YES";
      else
        cout << "NO";
    }
  }
}
