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