1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> V;

int main(){
  int n;
  cin>>n;
  V.resize(n+1);
  for(int i=0;i<n;i++){
  int a;
  cin>>a;
  V[a]++;
  }
  sort(V.begin(), V.end());
  int suma=0;
  for(int i = n;i>=0;i--){
    suma+=V[i];
    suma+=(V[i]-1);
    if(suma>=n){
    cout<<n-i+1<<"\n";
    return 0;
    }
  }
  return 0;
}