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
29
30
#include <cstdio>

using namespace std;

const int MAX_EXP = 201719;

int main() {
  int n;
  scanf("%d\n", &n);

  int exps[MAX_EXP+1] = {};
  int tmp;

  for(int i=0; i<n; i++) {
    scanf("%d", &tmp);
    exps[tmp] += 1;
  }

  int result;

  for(int i=0; i<MAX_EXP; i++) {
    if(exps[i] > 0)
      result = i;
    exps[i+1] += exps[i]/2;
  }

  printf("%d\n", result);

  return 0;
}