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