1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <cstdio>

int i, j, n, m, a[202000];
int main() {
    scanf("%d", &n);
    for(;i<n;i++) {
        scanf("%d", &j);
        a[j]++;
    }
    for(i=0;i<201900;i++){
      if(a[i]) {
        a[i+1] += a[i]/2;
        m = i;
      }
    }
    printf("%d\n", m);
    return 0;
}