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
//Piotr Zurek
#include <iostream>
#include <algorithm>

using namespace std;
int ans[201719];

int main()
{
    int n;
    cin>>n;
    int x;
    for(int i = 0 ; i < n ; i ++)
    {
        cin>>x;
        ans[x]++;
    }
    int maks = 0;
    for(int i = 1 ; i < 201719 ; i++)
    {
        ans[i] += ans[i-1]/2;
        if(ans[i] != 0) maks = i;
    }
    cout<<maks<<endl;
}