#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n];
  map<int, int> m;
  int cnt_distinct = 0, m_max = 0, m_min = 1000000001;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (m[arr[i]] == 0) {
      m[arr[i]] = 1;
      cnt_distinct++;
    }
    if (m_min > arr[i]) {
      m_min = arr[i];
    }
    if (m_max < arr[i]) {
      m_max = arr[i];
    }
  }
  if (cnt_distinct < 3) {
    printf("YES\n");
    return 0;
  }
  if (cnt_distinct > 3) {
    printf("NO\n");
    return 0;
  }
  if ((m_max + m_min) % 2) {
    printf("NO\n");
    return 0;
  }
  int m_mid = (m_max + m_min) >> 1;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    if (arr[i] != m_max && arr[i] != m_min && arr[i] != m_mid) {
      ans = false;
      break;
    }
  }
  if (ans) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
