1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>
#include <tuple>

constexpr int max_n = 5e5 + 10;
int tab[max_n];
int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);

	int n;
	std::cin >> n;
	int a;
	for (int i = 0; i < n; ++i)
		std::cin >> a, ++tab[a - 1];
	std::sort(tab, tab + n, std::greater<int>());
	int sum = 0;
	int i = 0;
	while (sum < n)
		sum += 2 * tab[i++] - 1;
	std::cout << i;
}