1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//泥の分際で私だけの大切を奪おうだなん
#include<bits/stdc++.h>
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int a[1<<19];
signed main()
{
	int n=read();
	for(int i=1; i<=n; ++i) ++a[read()];
	sort(a+1,a+n+1);
	for(int i=n,A=n,B=0; i>=1; --i)
	{
		A-=a[i],B+=a[i]-1;
		if(A<=B) printf("%d\n",n+1-i),exit(0);
	}
	printf("%d\n",n);
	return 0;
}