1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
using namespace std;

int main (){
    int MAX = 210000;
    int A[MAX];
    for (int i = 0; i < MAX; ++i)
    A[i] = 0;
    int n, p;
    cin >> n;
    while(n--){
        cin >> p;
        A[p]++;
    }
    for (int i = 1; i < MAX; ++i){
        A[i] += A[i - 1] / 2;
    }
    for (int i = MAX - 1; i >= 0; --i){
        if (A[i] > 0){
            cout << i << endl;
            return 0;
        }
    }
}