#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 1e6;
const int INF = 2147483647;
set<int> s;
int n, a[MAXN];
int mn, mx, md;
int main() {
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
  }
  if (s.size() > 3)
    cout << "NO\n";
  else if (s.size() == 1)
    cout << "YES\n";
  else if (s.size() == 2)
    cout << "YES\n";
  else {
    mn = mx = md = a[1];
    for (int i = 1; i <= n; i++) {
      mn = min(mn, a[i]);
      mx = max(mx, a[i]);
    }
    for (int i = 1; i <= n; i++)
      if (a[i] != mn && a[i] != mx) md = a[i];
    if (abs(mx - md) == abs(mn - md))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
