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

using namespace std;

int main()
{
	int size = 201800;
	int n, k;
	int b[size];
	
	scanf("%d",&n);
	
	for (int i=0; i<size; i++)
		b[i]=0;
	
	int maxNumber = 0;
	for (int i=0; i<n; i++)
	{
		scanf("%d",&k);
		b[k]++;
		
		if (k > maxNumber)
			maxNumber = k;
	}
	
	int i=0;
	while (i <= maxNumber || b[i] != 0)
	{
		b[i+1] += b[i]/2;
		i++;
	}
	
	printf("%d\n",i-1);
}