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
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>

using namespace std;

vector<int> Read()
{
	int n;
	scanf("%d", &n);
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		a[x - 1]++;
	}
	vector<int> b;
	for (int x : a)
		if (x > 0)
			b.push_back(x);
	ranges::sort(b);
	ranges::reverse(b);
	return b;
}

int main()
{
	vector<int> a = Read();
	int64_t s = 0;
	for (int x : a)
		s += x;
	int64_t p = 0;
	int k = 0;
	while (p < s && k < (int) a.size())
	{
		s -= a[k];
		p += a[k] - 1;
		k++;
	}
	printf("%d\n", k);
	return 0;
}