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 <stdio.h>

#define MAXN 256000
int nn[MAXN];

int main() {
  int i, n;
  for (i=0;i<MAXN;i++)
    nn[i] = 0;
  scanf("%d", &n);
  for (i=0;i<n;i++) {
    int a;
    scanf("%d", &a);
    nn[a]++;
  }
  for (i=1;i<MAXN;i++)
    nn[i] += nn[i-1]/2;
  for (i=MAXN-1;i>=0;i--)
    if (nn[i]!=0) {
      printf("%d\n", i);
      break ;
    }
  return 0;
}