program negative_doubling
  implicit none
  integer :: n, d(2,200000) = 0, m, i, j, x, y
  integer(8) :: a(200000) = 0_8, p, q, dp(2,200000,0:15) = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  do j = 1, 2
    do i = 1, n-1
      p = a(i)
      q = a(i+1)
      if (p <= q) then
        do while (4_8*p <= q)
          d(j,i) = d(j,i)-1
          p = 4_8*p
        end do
      else
        do while (p > q)
          d(j,i) = d(j,i)+1
          q = 4_8*q
        end do
      end if
    end do
    a(1:n) = a(n:1:-1)
  end do
  do x = 0, 15
    dp(:,n,x) = int(2*x,8)
  end do
  do j = 1, 2
    do i = n-1, 1, -1
      do x = 0, 15
        y = max(x+d(j,i),0)
        if (y <= 15) then
          dp(j,i,x) = dp(j,i+1,y)+int(2*x,8)
        else
          dp(j,i,x) = dp(j,i+1,15)+int(2*x,8)+2_8*int(y-15,8)*int(n-i,8)
        end if
      end do
    end do
  end do
  dp(2,1:n,:) = dp(2,n:1:-1,:)
  do i = 1, n
    dp(2,i,:) = dp(2,i,:)+int(i,8)
  end do
  m = min(dp(1,1,0),dp(2,n,0))
  do i = 2, n
    m = min(m,dp(1,i,0)+dp(2,i-1,0))
  end do
  write(*,'(i0)') m
  stop
end program negative_doubling