#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j, a[100005], small = 9999999999, big = 0, count = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < small) {
      small = a[i];
    }
    if (a[i] > big) {
      big = a[i];
    }
  }
  j = big + small;
  if (j % 2 == 0) {
    j = j / 2;
    for (i = 1; i <= n; i++) {
      if (a[i] == big || a[i] == small || a[i] == j) {
        count = 0;
      } else {
        count = 1;
        break;
      }
    }
  } else {
    for (i = 1; i <= n; i++) {
      if (a[i] != big && a[i] != small) {
        count = 1;
        break;
      } else {
        count = 0;
      }
    }
  }
  if (count == 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
