#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n, i, j;
    long long v = 0, a[100000];

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (i = 0; i < n-1; i++) {
        for (j = i+1; j < n; j++) {
            long long tv = a[i] + a[j] - floor(log2(j - i));
            if (tv > v) {
                v = tv;
            }
        }
    }

    cout << v << endl;

    return 0;
}