#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a = -1, b = -1, c = -1;
  bool flag = false;
  for (long long i = 0; i < n; i++) {
    long long cur;
    cin >> cur;
    if (a == -1 || cur == a) {
      a = cur;
    } else if (b == -1 || cur == b) {
      b = cur;
    } else if (c == -1 || cur == c) {
      c = cur;
    } else {
      flag = true;
    }
  }
  if (flag)
    cout << "NO";
  else {
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    if (a == -1 || (a + c == b * 2))
      cout << "YES";
    else
      cout << "NO";
  }
  cin >> n;
  return 0;
}
