#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100000 + 10], b[10];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0;
  for (int i = 0; i < n && cnt < 4; i++) {
    if (a[i] != -1) {
      for (int j = i + 1; j < n; j++) {
        if (a[i] == a[j]) a[j] = -1;
      }
      b[cnt++] = a[i];
    }
  }
  if (cnt >= 4)
    cout << "NO";
  else if (cnt == 1 || cnt == 2)
    cout << "YES";
  else if (cnt == 3) {
    sort(b, b + cnt);
    if (2 * b[1] == b[0] + b[2])
      cout << "YES";
    else
      cout << "NO";
  }
}
