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

int main()
{
	
	int n;
	scanf("%d", &n);
	vector < int > nominal(201819);
	int max=0;
	for(int i=0; i < n; i++){
		int a;
		scanf("%d", &a);
		if(a>max){
			max=a;
		}
		nominal[a]++;
	}
	long long i=0;
	while(nominal[i]>0 || i<max){
		nominal[i+1]+=nominal[i]/2;
		i++;
	}
	printf( "%lld", i-1);
	return 0;
}