#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  set<int>::iterator it;
  int n, a[4], in, j = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> in;
    s.insert(in);
  }
  if (s.size() <= 2)
    cout << "YES";
  else if (s.size() >= 4)
    cout << "NO";
  else {
    for (it = s.begin(); it != s.end(); it++, j++) a[j] = *it;
    if (a[0] + a[2] == a[1] * 2)
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
