object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(sc: Scanner): Unit = {
    val Array(n, k) = sc.readLineInts
    val rawX = sc.readLineInts
    val zero = rawX.count(_ == 0)
    val positives = rawX.filter(_ > 0)
    val negatives = rawX.filter(_ < 0).reverse.map(_ * (-1))

    val K = k - zero

    def requiredTimes(firstDirection: Array[Int], secondDirection: Array[Int]): IndexedSeq[Option[Int]] = {
      (1 to K).map(firstShiftAmount =>
        if (firstShiftAmount > firstDirection.length) None
        else {
          val firstDirectionEdgeElement = firstDirection(firstShiftAmount - 1)
          val remaining = K - firstShiftAmount
          if (remaining == 0) {
            Some(firstDirectionEdgeElement)
          } else if(remaining > secondDirection.length) {
            None
          } else {
            val secondDirectionEdgeElement = secondDirection(remaining - 1)
            Some(2 * firstDirectionEdgeElement + secondDirectionEdgeElement)
          }
        }
      )
    }

    val answer = if (K == 0) {
      0
    } else {
      val times = requiredTimes(positives, negatives) ++ requiredTimes(negatives, positives)
      times.flatten.min
    }
    println(answer)
  }
}
