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
#include <cstdio>

const int MAX = 250005;

int t[MAX+100];

int main() {
	int n, a;
	scanf("%d", &n);
	
	for (int i=0; i<n; i++) {
		scanf("%d", &a);
		t[a]++;
	}
	
	int l = 0;
	int w = 0;
	
	for (int i=0; i<MAX; i++) {
		l += t[i];
		if (l > 0)
			w = i;
		l /= 2;
	}
	
	while (l > 0) {
		w++;
		l/=2;
	}
	
	printf("%d\n", w);
	
	return 0;
}