from sys import stdin

from itertools import repeat

def f(a):

    n = len(a)

    l = [0] * (n + 1)

    st = [(a[0], a[0], 1)]

    pu = st.append

    po = st.pop

    for i in range(1, n):

        ad = 0

        y = a[i]

        k = 1

        while st and y > st[-1][0]:

            x, z, q = po()

            c = (((y - 1) / x).bit_length() + 1) / 2 * 2

            ad += c * q

            k += q

            y = z << c

        pu((a[i], y, k))

        l[i+1] = l[i] + ad

    return l

 

def main():

    n = int(stdin.readline())

    a = list(map(int, stdin.readline().split(), repeat(10, n)))

    l = f(a)

    r = f(a[::-1])[::-1]

    ans = 10 ** 12

    for i in range(n + 1):

        if ans > l[i] + i + r[i]:

            ans = l[i] + i + r[i]

    print(ans)

main()

from sys import stdin

from itertools import repeat

def f(a):

    n = len(a)

    l = [0] * (n + 1)

    st = [(0, 0, 0, 1)]

    pu = st.append

    po = st.pop

    for i in range(1, n):

        ad = 0

        r = i

        u = 0

        k = 1

        while st:

            y = a[r] << u

            x = a[st[-1][0]]

            if x >= y:

                break

            _, r, u, q = po()

            c = 0

            while x < y:

                x *= 4

                c += 2

            ad += c * q

            k += q

            u += c

        pu((i, r, u, k))

        l[i+1] = l[i] + ad

    return l

 

def main():

    n = int(stdin.readline())

    a = list(map(int, stdin.readline().split(), repeat(10, n)))

    l = f(a)

    r = f(a[::-1])[::-1]

    ans = 10 ** 12

    for i in range(n + 1):

        if ans > l[i] + i + r[i]:

            ans = l[i] + i + r[i]

    print(ans)

main()

from sys import stdin
from itertools import repeat


def f(a):
    n = len(a)
    l = [0] * (n + 1)
    st = [(a[0], a[0], 1)]
    pu = st.append
    po = st.pop
    for i in range(1, n):
        ad = 0
        y = a[i]
        k = 1
        while st and y > st[-1][0]:
            x, z, q = po()
            c = (((y - 1) / x).bit_length() + 1) / 2 * 2
            ad += c * q
            k += q
            y = z << c
        pu((a[i], y, k))
        l[i + 1] = l[i] + ad
    return l


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split(), repeat(10, n)))
    l = f(a)
    r = f(a[::-1])[::-1]
    ans = 10**12
    for i in range(n + 1):
        if ans > l[i] + i + r[i]:
            ans = l[i] + i + r[i]
    print(ans)


main()

from sys import stdin
from itertools import repeat


def f(a):
    n = len(a)
    l = [0] * (n + 1)
    st = [(0, 0, 0, 1)]
    pu = st.append
    po = st.pop
    for i in range(1, n):
        ad = 0
        r = i
        u = 0
        k = 1
        while st:
            y = a[r] << u
            x = a[st[-1][0]]
            if x >= y:
                break
            _, r, u, q = po()
            c = 0
            while x < y:
                x *= 4
                c += 2
            ad += c * q
            k += q
            u += c
        pu((i, r, u, k))
        l[i + 1] = l[i] + ad
    return l


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split(), repeat(10, n)))
    l = f(a)
    r = f(a[::-1])[::-1]
    ans = 10**12
    for i in range(n + 1):
        if ans > l[i] + i + r[i]:
            ans = l[i] + i + r[i]
    print(ans)


main()

-    st = [(a[0], a[0], 1)] +    st = [(0, 0, 0, 1)] -        y = a[i] +        r = i +        u = 0 -        while st and y > st[-1][0]: -            x, z, q = po() -            c = (((y - 1) / x).bit_length() + 1) / 2 * 2 +        while st: +            y = a[r] << u +            x = a[st[-1][0]] +            if x >= y: +                break +            _, r, u, q = po() +            c = 0 +            while x < y: +                x *= 4 +                c += 2 -            y = z << c -        pu((a[i], y, k)) +            u += c +        pu((i, r, u, k))