#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  vector<int> vtmp(s.begin(), s.end());
  string ans = "NO";
  if ((int)vtmp.size() == 1 || (int)vtmp.size() == 2) {
    ans = "YES";
  }
  if ((int)vtmp.size() == 3 && (vtmp[2] - vtmp[1] == vtmp[1] - vtmp[0])) {
    ans = "YES";
  }
  cout << ans << endl;
  return 0;
}
