#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    mp[x]++;
  }
  int f = 0;
  for (int i = 0; i < n; i++) {
    int x = n - mp[v[i]];
    if (mp[v[i]] <= x + 1)
      continue;
    else {
      f = 1;
      break;
    }
  }
  if (f)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
