object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  implicit def toWith(value: Long): NumberWithExponent = value.toWithExp
  implicit class Converter(private val value : Long){
    def toWithExp: NumberWithExponent = NumberWithExponent(value, 0)
  }
  val n = readLine.trim.toInt
  val numbers = readLine.trim.split(' ').map(_.toLong)
  val minus = minCountOfSortWithMinusTo(numbers).toList
  val plus = minCountOfSortWithPlusAfter(numbers).toList
  println(
    (0::minus).zip(plus ++ List(0)).map{case (l, r) ⇒ l + r}.min
  )
  def minCountOfSortWithMinusTo(numbers: Array[Long]): Array[Int] = {
    var list = Nil: List[MinusSortedSequence]
    numbers.map{right ⇒
      val (c, n) = addMinus(right, list)
      list = n
      c
    }.also{arr ⇒
      for (i ← 1 until arr.length){
        arr(i) += arr(i - 1)
      }
    }
  }
  def minCountOfSortWithPlusAfter(numbers: Array[Long]): Array[Int] = {
    var list = Nil: List[PlusSortedSequence]
    numbers.reverse.map{left ⇒
      val (c, n) = addPlus(left, list)
      list = n
      c
    }.also{arr ⇒
      for (i ← 1 until arr.length){
        arr(i) += arr(i - 1)
      }
    }.reverse
  }

  def addPlus(addLeft: Long, prev: List[PlusSortedSequence] = Nil): (Int, List[PlusSortedSequence]) = {
    prev match {
      case Nil if addLeft > 0 ⇒ (0, PlusSortedSequence(addLeft, addLeft, 1)::Nil)
      case Nil ⇒ (1, PlusSortedSequence(addLeft * -2, addLeft * -2, 1)::Nil)
      case PlusSortedSequence(left, right, length)::t if left >= addLeft && addLeft >= 0 ⇒
        if (left >= addLeft * 4) (0, PlusSortedSequence(addLeft, addLeft, 1)::prev)
        else (0, PlusSortedSequence(addLeft, right, length + 1)::t)
      case PlusSortedSequence(left, _, _)::_ if left < addLeft ⇒
        val (count, next) = increaseWhile(prev, addLeft)
        addPlus(addLeft, next).let{case (c, n) ⇒ (c + count, n)}
      case _ ⇒ addPlus(addLeft * -2, prev).let{case (c, n) ⇒ (c + 1, n)}
    }
  }
  def addMinus(addRight: Long, prev: List[MinusSortedSequence] = Nil): (Int, List[MinusSortedSequence]) = {
    prev match{
      case Nil if addRight < 0 ⇒ (0, MinusSortedSequence(addRight, addRight, 1)::Nil)
      case Nil ⇒ (1, MinusSortedSequence(addRight * -2, addRight * -2, 1)::Nil)
      case MinusSortedSequence(left, right, length)::t if right <= addRight && addRight <= 0 ⇒
        if (right <= addRight * 4) (0, MinusSortedSequence(addRight, addRight, 1)::prev)
        else (0, MinusSortedSequence(left, addRight, length + 1)::t)
      case MinusSortedSequence(_, right, _)::_ if addRight < right ⇒
        val (count, next) = decreaseWhile(prev, addRight)
        addMinus(addRight, next).let{case (c, n) ⇒ (c + count, n)}
      case _ ⇒ addMinus(addRight * -2, prev).let{case (c, n) ⇒ (c + 1, n)}
    }
  }
  def increaseWhile(list: List[PlusSortedSequence], target: NumberWithExponent): (Int, List[PlusSortedSequence]) = {
    list match {
      case h::_ if h.left < target ⇒ increaseWhile(increase(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}
      case _ ⇒ (0, list)
    }
  }
  def decreaseWhile(list: List[MinusSortedSequence], target: NumberWithExponent): (Int, List[MinusSortedSequence]) = {
    list match {
      case h::_ if h.right > target ⇒
        decreaseWhile(decrease(list), target).let{case (c, l) ⇒ (c + h.length * 2, l)}
      case _ ⇒ (0, list)
    }
  }
  def increase(list: List[PlusSortedSequence]): List[PlusSortedSequence] = {
    list match {
      case PlusSortedSequence(left, r, len1)::PlusSortedSequence(l, right, len2)::t if r.copy(exponent = r.exponent + 4) > l ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right, len1 + len2)::t
      case PlusSortedSequence(left, right, length)::t ⇒ PlusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t
      case Nil ⇒ Nil
    }
  }
  def decrease(list: List[MinusSortedSequence]): List[MinusSortedSequence] = {
    list match {
      case MinusSortedSequence(l, right, length)::MinusSortedSequence(left, r, len)::t if l.copy(exponent = l.exponent + 4) > r ⇒ MinusSortedSequence(left, right.copy(exponent = right.exponent + 2), length + len)::t
      case MinusSortedSequence(left, right, length)::t ⇒  MinusSortedSequence(left.copy(exponent = left.exponent + 2), right.copy(exponent = right.exponent + 2), length)::t
      case Nil ⇒ Nil
    }
  }
  case class PlusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)
  case class MinusSortedSequence(left: NumberWithExponent, right: NumberWithExponent, length: Int)
  case class NumberWithExponent(value: Long, exponent: Int) extends Ordered[NumberWithExponent] {
    override def compare(that: NumberWithExponent): Int = toLogWithSign.compare(that.toLogWithSign)
    private val sign: Int = math.signum(value).toInt * (if (exponent % 2 == 1) -1:Int else 1: Int)
    private val toLogWithSign: Double = (math.log(math.abs(value)) + math.log(2) * exponent) * sign
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}