1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <stdio.h>
const int S = 210000;
int tab[S], M, n, x;
int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; i ++){
        scanf("%d", &x);
        tab[x] ++;
    }
    for (int i = 0; i < S - 2; i ++)
        tab[i + 1] += (tab[i] / 2);
    for (int i = S  - 2; i >= 0; i --)
        if (tab[i]){
            printf("%d", i);
            return 0;
        }
}