from collections import deque

 

q = deque([]) 



def ct(a,b):

    ans = 0

    while abs(a)<abs(b):

        ans += 2

        a *= 4

    return ans



N = int(eval(input()))

A = [int(a) for a in input().split()]



# A = [3, 1, 4, 1]

# N = len(A)





X = [0] * (N)

Y = [0] * (N)



a = -1

for i in range(N):

    b = a

    if i > 0:

        X[i] = X[i-1]

    else:

        X[i] = 0

    a = A[i]

    t = 0

    if a > 0:

        X[i] += 1

        a *= -2

    

    if i > 0:

        t = 0

        r = b/a

        while r >= 4:

            q.append(i)

            r /= 4

            

        while abs(a)>abs(b):

            if len(q) == 0:

                X[i] += 2 * i

            else:

                X[i] += 2 * (i - q.pop())

            b *= 4

    

q = deque([]) 

a = -1

for i in range(N):

    b = a

    if i > 0:

        Y[i] = Y[i-1]

    else:

        Y[i] = 0

    a = A[N-1-i]

    t = 0

    if a < 0:

        Y[i] += 1

        a *= -2

    

    if i > 0:

        t = 0

        r = b/a

        while r >= 4:

            q.append(i)

            r /= 4

            

        while abs(a)>abs(b):

            if len(q) == 0:

                Y[i] += 2 * i

            else:

                Y[i] += 2 * (i - q.pop())

            b *= 4



mi = min(X[-1], Y[-1])

for i in range(N-1):

    if X[i]+Y[-2-i] < mi:

        mi = X[i]+Y[-2-i]

print(mi)
def f(A, s):

    X = [0] * N

    q = []

    a = 0

    for i in range(N):

        b = a

        X[i] = X[i-1]

        a = A[i]

        if a * s < 0:

            X[i] += 1

            a *= -2



        if i == 0:

            continue

            

        r = b/a

        while r >= 4:

            q.append(i)

            r /= 4



        while r < 1:

            X[i] += 2 * (i - (0 if len(q) == 0 else q.pop()))

            r *= 4

            

    return X



N = int(eval(input()))

A = [int(a) for a in input().split()]

X = f(A,-1)

Y = f(A[::-1],1)



mi = min(X[-1], Y[-1])

for i in range(N-1):

    mi = min(mi, X[i] + Y[-2-i])

print(mi)
from collections import deque

q = deque([])


def ct(a, b):
    ans = 0
    while abs(a) < abs(b):
        ans += 2
        a *= 4
    return ans


N = int(eval(input()))
A = [int(a) for a in input().split()]
# A = [3, 1, 4, 1]
# N = len(A)
X = [0] * (N)
Y = [0] * (N)
a = -1
for i in range(N):
    b = a
    if i > 0:
        X[i] = X[i - 1]
    else:
        X[i] = 0
    a = A[i]
    t = 0
    if a > 0:
        X[i] += 1
        a *= -2
    if i > 0:
        t = 0
        r = b / a
        while r >= 4:
            q.append(i)
            r /= 4
        while abs(a) > abs(b):
            if len(q) == 0:
                X[i] += 2 * i
            else:
                X[i] += 2 * (i - q.pop())
            b *= 4
q = deque([])
a = -1
for i in range(N):
    b = a
    if i > 0:
        Y[i] = Y[i - 1]
    else:
        Y[i] = 0
    a = A[N - 1 - i]
    t = 0
    if a < 0:
        Y[i] += 1
        a *= -2
    if i > 0:
        t = 0
        r = b / a
        while r >= 4:
            q.append(i)
            r /= 4
        while abs(a) > abs(b):
            if len(q) == 0:
                Y[i] += 2 * i
            else:
                Y[i] += 2 * (i - q.pop())
            b *= 4
mi = min(X[-1], Y[-1])
for i in range(N - 1):
    if X[i] + Y[-2 - i] < mi:
        mi = X[i] + Y[-2 - i]
print(mi)

def f(A, s):
    X = [0] * N
    q = []
    a = 0
    for i in range(N):
        b = a
        X[i] = X[i - 1]
        a = A[i]
        if a * s < 0:
            X[i] += 1
            a *= -2
        if i == 0:
            continue
        r = b / a
        while r >= 4:
            q.append(i)
            r /= 4
        while r < 1:
            X[i] += 2 * (i - (0 if len(q) == 0 else q.pop()))
            r *= 4
    return X


N = int(eval(input()))
A = [int(a) for a in input().split()]
X = f(A, -1)
Y = f(A[::-1], 1)
mi = min(X[-1], Y[-1])
for i in range(N - 1):
    mi = min(mi, X[i] + Y[-2 - i])
print(mi)

-from collections import deque - -q = deque([]) - - -def ct(a, b): -    ans = 0 -    while abs(a) < abs(b): -        ans += 2 -        a *= 4 -    return ans +def f(A, s): +    X = [0] * N +    q = [] +    a = 0 +    for i in range(N): +        b = a +        X[i] = X[i - 1] +        a = A[i] +        if a * s < 0: +            X[i] += 1 +            a *= -2 +        if i == 0: +            continue +        r = b / a +        while r >= 4: +            q.append(i) +            r /= 4 +        while r < 1: +            X[i] += 2 * (i - (0 if len(q) == 0 else q.pop())) +            r *= 4 +    return X -# A = [3, 1, 4, 1] -# N = len(A) -X = [0] * (N) -Y = [0] * (N) -a = -1 -for i in range(N): -    b = a -    if i > 0: -        X[i] = X[i - 1] -    else: -        X[i] = 0 -    a = A[i] -    t = 0 -    if a > 0: -        X[i] += 1 -        a *= -2 -    if i > 0: -        t = 0 -        r = b / a -        while r >= 4: -            q.append(i) -            r /= 4 -        while abs(a) > abs(b): -            if len(q) == 0: -                X[i] += 2 * i -            else: -                X[i] += 2 * (i - q.pop()) -            b *= 4 -q = deque([]) -a = -1 -for i in range(N): -    b = a -    if i > 0: -        Y[i] = Y[i - 1] -    else: -        Y[i] = 0 -    a = A[N - 1 - i] -    t = 0 -    if a < 0: -        Y[i] += 1 -        a *= -2 -    if i > 0: -        t = 0 -        r = b / a -        while r >= 4: -            q.append(i) -            r /= 4 -        while abs(a) > abs(b): -            if len(q) == 0: -                Y[i] += 2 * i -            else: -                Y[i] += 2 * (i - q.pop()) -            b *= 4 +X = f(A, -1) +Y = f(A[::-1], 1) -    if X[i] + Y[-2 - i] < mi: -        mi = X[i] + Y[-2 - i] +    mi = min(mi, X[i] + Y[-2 - i])