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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;

#define PB push_back
#define MP make_pair
#define LL long long

#define PII pair<int,int>
#define VI vector<int>
#define LD long double
#define st first
#define fst first
#define nd second
#define snd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for (int i = (a); i<=(b); i++)
#define FORD(i, a, b) for (int i = (a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define rep(i,n) REP(i,n)
typedef vector<int> vi;
template<class C> void mini(C &a4, C b4) {a4 = min(a4, b4);}
typedef long long ll;
typedef pair<int, int> Pii;
typedef vector<Pii> vpii;
template<class C> void maxi(C & a4, C b4) {a4 = max(a4, b4);}
const int maxn = 3e5;
int ile[maxn];
int n;
int main()
{
    scanf("%d", &n);
    rep(i,n)
    {
        int x;
        scanf("%d", &x);
        ++ile[x];
    }
    rep(i,maxn-1)
        ile[i+1] += ile[i] / 2;
    int m = 0;
    rep(i,maxn)
        if(ile[i] > 0)
            m = i;
    printf("%d\n", m);
}