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
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

// #define dbg(s, ...) printf(s "\n", __VA_ARGS__)
#define dbg(s, ...)

#define MAXN 202000

int main()
{
	int z;
	scanf("%d", &z);

	int max = 0;
	vector<int> num(MAXN);

	for (int i = 0; i < z; i++) {
		int n;
		scanf("%d", &n);

		num[n] += 1;
	}

	int c = 0;
	int best = 0;
	for (int i = 0; c || i < MAXN; i++) {
		c = c / 2 + num[i];
		if ( c > 0 ) {
			best = i;
		}
	}

	printf("%d\n", best);

	return 0;
}