#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 1, cnt1 = 1;
  int check = 0;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int res = unique(a, a + n) - a;
  if (res > 3)
    cout << "NO";
  else if (a[0] + a[2] == a[1] * 2)
    cout << "YES";
  else if (res < 3)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
