#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, p = -1;
  cin >> n;
  long a[n], b[3];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (p == 2 && a[i] != b[0] && a[i] != b[1] && a[i] != b[2]) {
      cout << "NO";
      return 0;
    }
    if (p == 1) {
      if (b[0] != a[i] && b[1] != a[i]) {
        b[++p] = a[i];
      }
    } else if (p == -1) {
      b[++p] = a[i];
    } else if (p == 0) {
      if (b[0] != a[i]) {
        b[++p] = a[i];
      }
    }
  }
  if (p == 0) {
    cout << "YES";
    return 0;
  }
  sort(b, b + 3);
  if (p == 1) {
    cout << "YES";
    return 0;
  }
  if (b[1] - b[0] == b[2] - b[1]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
