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>

using namespace std;

int data[202000], n, in, farth;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        data[in]++;
    }
    for (int i = 0; i < 201990; ++i)
    {
        if (data[i] > 0)
        {
            farth = i;
            data[i + 1] += data[i] / 2;
        }
    }
    cout << farth;
    return 0;
}