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
38
39
40
41
42
43
/*
 * SKA
 * Autor: Szymon Tur
 */


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	vector<int> ska;
	int n=0,x=0,m=0,max,l=0;
	cin >> n;
	for (int i=0;i<n;i++) 
	{
		cin >> x;
		ska.push_back(x);
	}
	sort(ska.begin(),ska.end());
	max = ska[n-1];
	int j=0;
	while (j<n)
	{
		if (ska[j]==l)
		{
			++m;
			++j;
		}
		else
		{
			++l;
			m/=2;
		}
	}
	m = (int)floor(log2(m));
	cout << max + m;
	return 0;
}