output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: N = int(input())
  A = list(map(int, input().split()))
  c = 0
  a = 0
  index = 0
  buf = [-1 for i in range(N)]
  for i in range(N - 1):
      if A[i + 1] < A[i] and a == 0:
          buf[i] = i
      elif A[i + 1] >= A[i] and index == 0:
          a = 1
          index = i + 1
      elif A[i + 1] >= A[index] and index != 0:
          index = i + 1
      elif A[index] > A[i + 1] and index != 0:
          buf[i + 1] = i + 1
  if len(buf) > 0:
      if buf[0] == 0:
          i = 0
          while buf[i] != -1:
              A[buf[i]] = -2 * A[buf[i]]
              i += 1
              c += 1
      for x in buf:
          if x != -1 and x != 0:
              while A[x - 1] > A[x]:
                  A[x] = 4 * A[x]
                  c += 2
  print(c)
  
problem_description: Statement
  
  There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the
  following operation on these integers any number of times:
  
    * Choose 1 \leq i \leq N and multiply the value of A_i by -2.
  
  Notice that he multiplies it by **minus** two.
  
  He would like to make A_1 \leq A_2 \leq ... \leq A_N holds. Find the minimum
  number of operations required. If it is impossible, print `-1`.
samples: [{"input": "4\n    3 1 4 1", "output": "3\n    \n\nOne possible solution is:\n\n  * Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now 3, 1, 4, -2.\n  * Choose i=1 and multiply the value of A_1 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, -2.\n  * Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, 4.\n\n* * *"}, {"input": "5\n    1 2 3 4 5", "output": "0\n    \n\nA_1 \\leq A_2 \\leq ... \\leq A_N holds before any operation is performed.\n\n* * *"}, {"input": "8\n    657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097", "output": "7"}]