#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
unsigned int arr[MAX];
int main() {
  unsigned int n{}, x{}, a{}, i{};
  set<unsigned int> s;
  cin >> n;
  for (int i{0}; i < n; i++) cin >> x, s.insert(x);
  for (auto s : s) arr[i++] = s;
  if (s.size() > 3 || (s.size() == 3 && arr[1] * 2 != arr[0] + arr[2]))
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
