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
#include <iostream>
#include <cstdio>
using namespace std;

int t[1000000];

int main(int argc, char const *argv[])
{
	int n; 
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int a;
		scanf("%d",&a);
		++t[a];
	}
	int wyn=0;
	for (int i = 0; i < 1000000-1; ++i)
	{
		t[i+1]+=t[i]/2;
		if(t[i])	wyn=i;
	}
	printf("%d", wyn);
	return 0;
}