#include #include #include using namespace std; int n,i, j, k, m, u; struct info1 { long long x; int y; }; info1 a[100003]; bool cmp(info1 o1, info1 o2) { return o1.x > o2.x; } int abs(int x) { return (x < 0) ? (-x) : (x); } long long mx(long long x, long long y) { return (x > y) ? (x) : (y); } int main() { cin >> n; for (i = 1; i <= n; ++i) { cin >> a[i].x; a[i].y = i; } sort(a + 1, a + n + 1, cmp); //for (i = 1; i <= n; ++i) cout << a[i].x << ' ' << a[i].y << "\n"; long long sol = 0; for (i = 2; i <= n; ++i) { int nr=floor(log2(abs(a[1].y - a[i].y))); sol = max(sol, a[1].x+ a[i].x-nr); } cout << sol; return 0; }