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
37
#include<iostream>
using namespace std;
int T[202001];

int main()
{
	int n, max, i, flaga;
	cin >> n;
	max = 0;
	for (int a = 0; a < 202001; a++)
		T[a] = 0;

	for (int a = 0; a < n; a++) 
	{
		cin >> i;
		T[i]++;

		if (i > max)
			max = i;
	}
	for (int a = 0; a < max + 50; a++)
		T[a + 1] += T[a] / 2;

	i = max + 50;
	flaga = 1;

	while (flaga == 1)
	{
		if (T[i] > 0)
		{
			cout << i << "\n";
			flaga = 0;
		}
		i--;
	}
	return 0;
}