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

#define MAXN 1000100

int dane[ MAXN ];
int nominaly[ 300000 ];

int main()
{
    int n;
    scanf( "%d", &n );
    for( int i = 0; i < n; ++i )
    {
        scanf( "%d", dane + i );
        ++nominaly[ dane[ i ] ];
    }
    int maks = 0;
    for( int i = 0; i < 299999; ++i )
    {
        int a = nominaly[ i ];
        nominaly[ i + 1 ] += a/2;
        if( nominaly[ i + 1 ] ) maks = i+1;
    }
    printf("%d", maks );
}