#include <bits/stdc++.h>
using namespace std;
vector<int> v;
map<int, bool> m;
int main() {
  int n;
  cin >> n;
  int a[n];
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (!m[x]) {
      m[x] = 1;
      v.push_back(x);
    }
  }
  if (v.size() > 3)
    puts("NO");
  else {
    if (v.size() == 3) {
      sort(v.begin(), v.end());
      if (v[2] - v[1] == v[1] - v[0])
        return puts("YES");
      else
        return puts("NO");
    } else
      puts("YES");
  }
  return 0;
}
