#include <bits/stdc++.h>
using namespace std;
long long arr[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  set<int> st;
  sort(arr, arr + n);
  for (int i = 0; i < n - 1; ++i) st.insert(abs(arr[i] - arr[i + 1]));
  if (n == 1)
    cout << "YES";
  else if (n <= 3) {
    if (st.size() == 1)
      cout << "YES";
    else if (st.size() == 2 && st.count(0))
      cout << "YES";
    else
      cout << "NO";
  } else {
    if (st.size() == 2) {
      if (st.count(0))
        cout << "YES";
      else
        cout << "NO";
    } else if (st.size() == 1 && (arr[1] - arr[0]) == 0)
      cout << "YES";
    else
      cout << "NO";
  }
}
