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
// Beniamin Gajecki
#include <iostream>
#include <cmath>
#include <vector>

template <typename t1>
t1 getMaxPower(t1 a)
{
    t1 x = 2, power = 1;
    if(a >= 2)
    {
        while(a >= x)
        {
            power++;
            x = pow(2, power);
        }
        return power - 1;
    }
    else
        return 0;
}

int main()
{
    unsigned n;
    std::cin>>n;
    if(1 <= n <= 1000000)
    {
        unsigned money = 0, coin;
        for(unsigned i = 0; i<n; ++i)
        {
            std::cin>>coin;
            money += pow(2, coin);
        }
        std::cout<<getMaxPower<unsigned>(money);
    }
    return 0;
}