#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long long f(long long a, long long b) {
    if (a <= b) {
        long long res = 0;
        while (a * 4 <= b) {
            a *= 4;
            res -= 2;
        }
        return res;
    } else {
        long long res = 0;
        while (a > b) {
            b *= 4;
            res += 2;
        }
        return res;
    }
}

const int N = 1 << 18;
long long lazy[N * 2];
int dat[N * 2];
long long dat2[N * 2];

void apply(int k, long long v, int s) {
    lazy[k] += v;
    dat[k] += v;
    dat2[k] += v * s;
}

void push(int k, int s) {
    apply(k * 2 + 0, lazy[k], s / 2);
    apply(k * 2 + 1, lazy[k], s / 2);
    lazy[k] = 0;
}

void update(int l, int r, long long v, int k = 1, int ll = 0, int rr = N) {
    if (rr <= l || r <= ll) return;
    if (l <= ll && rr <= r) {
        apply(k, v, rr - ll);
        return;
    }
    push(k, rr - ll);
    update(l, r, v, k * 2 + 0, ll, ll + rr >> 1);
    update(l, r, v, k * 2 + 1, ll + rr >> 1, rr);
    dat[k] = min(dat[k * 2], dat[k * 2 + 1]);
    dat2[k] = dat2[k * 2] + dat2[k * 2 + 1];
}

int query(int l, int r, int k = 1, int ll = 0, int rr = N) {
    if (rr <= l || r <= ll) return 1e9;
    if (l <= ll && rr <= r) return dat[k];
    push(k, rr - ll);
    int vl = query(l, r, k * 2 + 0, ll, ll + rr >> 1);
    int vr = query(l, r, k * 2 + 1, ll + rr >> 1, rr);
    return min(vl, vr);
}

long long query2(int l, int r, int k = 1, int ll = 0, int rr = N) {
    if (rr <= l || r <= ll) return 0;
    if (l <= ll && rr <= r) return dat2[k];
    push(k, rr - ll);
    long long vl = query2(l, r, k * 2 + 0, ll, ll + rr >> 1);
    long long vr = query2(l, r, k * 2 + 1, ll + rr >> 1, rr);
    return vl + vr;
}

int n;
int result;

bool bs(int l, int r, int v, int k = 1, int ll = 0, int rr = N) {
    if (rr <= l || r <= ll) return false;
    if (l <= ll && rr <= r) {
        if (dat[k] < v) {
            if (rr - ll == 1) {
                result = ll;
                return true;
            }
            push(k, rr - ll);
            if (bs(l, r, v, k * 2 + 0, ll, ll + rr >> 1)) return true;
            if (bs(l, r, v, k * 2 + 1, ll + rr >> 1, rr)) return true;
        }
        return false;
    }
    push(k, rr - ll);
    if (bs(l, r, v, k * 2 + 0, ll, ll + rr >> 1)) return true;
    if (bs(l, r, v, k * 2 + 1, ll + rr >> 1, rr)) return true;
    return false;
}

void fall(int k, int v) {
    if (v == 0) return;
    result = n;
    bs(k, n, v);
    update(k, result, -v);
    if (result < n) {
        fall(result, query(result, result + 1));
    }
}

vector<long long> g(vector<long long> a) {
    for (int i = 0; i < N * 2; i++) {
        lazy[i] = 0;
        dat[i] = 0;
        dat2[i] = 0;
    }
    vector<long long> b(n);
    for (int i = 1; i < n; i++) {
        b[i] = max(0LL, b[i - 1] + f(a[i - 1], a[i]));
    }
    for (int i = 0; i < n; i++) {
        dat[i + N] = b[i];
        dat2[i + N] = b[i];
    }
    for (int i = N - 1; i >= 1; i--) {
        dat[i] = min(dat[i * 2], dat[i * 2 + 1]);
        dat2[i] = dat2[i * 2] + dat2[i * 2 + 1];
    }
    vector<long long> res(n);
    for (int i = 0; i + 1 < n; i++) {
        fall(i, query(i, i + 1));
        res[i] = query2(i, n);
    }
    return res;
}

int main() {
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<long long> R = g(a);
    reverse(a.begin(), a.end());
    vector<long long> L = g(a);
    reverse(L.begin(), L.end());
    long long ans = min(R[0], n + L[n - 1]);
    for (int i = 1; i < n; i++) {
        ans = min(ans, i + L[i - 1] + R[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 20296