1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>

int i=0, n, a, tab[205001], maks=0;

int main(){
	scanf ("%d", &n);
	while (n--){
		scanf ("%d", &a);
		tab[a]++;
	}
	i=1;
	
	while (i<205001){
		tab[i]+=tab[i-1]/2;
		if (tab[i]!=0)	maks=i;
		i++;
	}
	
	printf ("%d", maks);
return 0;}