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>

int main() {
	const int POWER_SIZE = 201718 + 1;
	int power[POWER_SIZE] = {0};
	int n, a;

	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		std::cin >> a;
		++power[a];
	}

	int i, result = 0;
	int sum = 0;
	for (i = 0; i < POWER_SIZE; ++i) {
		sum = (sum / 2) + power[i];
		if (sum > 0)
			result = i;
	}
	sum /= 2;
	while (sum > 0) {
		++result;
		sum /= 2;
	}
	std::cout << result << std::endl;

	return 0;
}