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

const int MAX_LOGN = 50;
const int MAX_NUM = 201718;

int t[MAX_LOGN + MAX_NUM] = {0};

void init_ios()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
}

int main() {
    init_ios();

    int n;
    std::cin >> n;

    for (int j = 0; j < n; ++j)
        std::cin >> t[j];

    int result = 0;

    for (int j = 0; j < MAX_LOGN + MAX_NUM - 1; ++j)
    {
        result = (t[j] > 1) ? j : result;
        t[j + 1] += t[j] >> 1;
    }

    std::cout << result;

    return 0;
}