1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <iostream>

int main(int argc, char **argv) {
  int count;
  scanf("%d", &count);
  std::vector<int> c(250000);
  int result = 0;
  for (int i = 0; i < count; i++) {
    int n;
    scanf("%d", &n);
    while (++c[n] % 2 == 0) {
      n++;
    }
    result = std::max(result, n);
  }
  printf("%d\n", result);
  return 0;
}