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
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>

int main()
{
    int n;
    std::map<int, int> nom;

    scanf("%d", &n);

    for(int i = 0; i < n; ++i)
    {
        int x;

        scanf("%d", &x);
        ++nom[x];
    }

    for(auto p : nom)
        if(p.second > 1)
            for(int j = 1; j <= 30; ++j)
                if((p.second & (1 << j)) == 1 << j)
                    ++nom[p.first + j];

    printf("%d\n", nom.rbegin()->first);
}