#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  vector<int> v;
  cin >> n;
  long long int sum = 0;
  map<int, int> m1;
  for (int i = 0; i < n; i++) {
    cin >> k;
    if (m1[k] == 0) {
      m1[k]++;
      v.push_back(k);
      sum += k;
    }
  }
  if (v.size() <= 2) {
    cout << "YES" << endl;
    return 0;
  }
  if (sum % v.size() != 0) {
    cout << "NO" << endl;
  } else {
    int p = sum / v.size(), qq, cnt = 0;
    int flag = 0;
    sort(v.begin(), v.end());
    for (int i = 0, j = v.size() - 1; i < v.size(), j >= 0; i++, j--) {
      if (i == j or j < i) {
        break;
      } else if (v[i] == p) {
        continue;
      } else {
        if (cnt == 0) {
          if (v[i] < p) {
            int val = p - v[i];
            qq = val;
            if (v[j] - val != p) {
              flag = 1;
              break;
            }
          }
          cnt++;
        } else {
          if (v[i] < p) {
            int val = p - v[i];
            if (v[j] - val != p || val != qq) {
              flag = 1;
              break;
            }
          }
        }
      }
    }
    if (flag == 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
