#include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b) { return a < b ? a : b; }
int getMedian(int ai[100001], int n) {
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    if (m.find(ai[i]) != m.end()) {
      m[ai[i]] = m[ai[i]] + 1;
    } else
      m[ai[i]] = 1;
  }
  int temp = (m.size() - 1) / 2, k = 0, median;
  for (map<int, int>::iterator it = m.begin(); k <= temp; ++it, ++k) {
    median = it->first;
  }
  return median;
}
int main() {
  int n, ai[100001];
  bool isPossible;
  scanf("\n%d", &n);
  for (int i = 0; i < n; i++) scanf("\n%d", &ai[i]);
  int median = getMedian(ai, n);
  bool isDiffSet = false;
  int globalDiff, diff;
  isPossible = true;
  for (int i = 0; i < n; i++) {
    diff = ai[i] - median < 0 ? median - ai[i] : ai[i] - median;
    if (!diff) continue;
    if (isDiffSet) {
      if (diff != globalDiff) {
        isPossible = false;
        break;
      }
    } else {
      globalDiff = diff;
      isDiffSet = true;
    }
  }
  printf("%s\n", isPossible ? "YES" : "NO");
  return 0;
}
