#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0, m = 0, flag = 0;
  cin >> n;
  int a[n];
  map<int, int> m1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    m1[a[i]]++;
  }
  for (auto it = m1.begin(); it != m1.end(); it++) {
    if (it->second > n / 2) {
      m = it->second;
      flag = 1;
    }
    sum = sum + it->second;
  }
  if (flag == 1) {
    sum = sum - m;
    if (sum == m - 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  if (flag == 0) {
    cout << "YES" << endl;
  }
  return 0;
}
