#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag = 0;
  cin >> n;
  long long x, p = -1, q = -1, r = -1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (p == -1) {
      p = x;
    } else if (q == -1) {
      if (x < p) {
        q = p;
        p = x;
      } else if (x != p) {
        q = x;
      } else {
      }
    } else if (r == -1) {
      if (x < p) {
        r = q;
        q = p;
        p = x;
      } else if (x < q && x != p) {
        r = q;
        q = x;
      } else if (x != p && x != q) {
        r = x;
      } else {
      }
    } else if (x == p || x == q || x == r) {
      continue;
    } else {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    if (r >= 0) {
      if ((r - q) == (q - p))
        cout << "YES";
      else
        cout << "NO";
    } else if (q >= 0) {
      cout << "YES";
    } else if (p >= 0)
      cout << "YES";
    else {
    }
  } else
    cout << "NO";
  return 0;
}
