#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *arr, min, max, x, ans = 0, y;
  cin >> n;
  arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i == 0) min = max = arr[i];
    if (arr[i] < min) min = arr[i];
    if (arr[i] > max) max = arr[i];
  }
  x = min + max;
  if (x % 2 != 0)
    ans = 1;
  else {
    x /= 2;
    y = x - min;
    for (int i = 0; i < n; i++) {
      if (arr[i] > x && arr[i] - y != x) ans = 1;
      if (arr[i] < x && arr[i] + y != x) ans = 1;
    }
  }
  int count = 1;
  sort(arr, arr + n);
  for (int i = 1; i < n; i++)
    if (arr[i] != arr[i - 1]) count++;
  if (count == 2) ans = 0;
  if (ans == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
