// C - Candles
// https://abc107.contest.atcoder.jp/tasks/arc101_a

import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val xs: Array[Int] = readLine.split(" ").map(_.toInt)

  val edges: List[(Int, Int)] = List.range(0, n-k).map(i => (xs(i), xs(i+k-1)))

  val lengths = edges.map(edge => {
    val left  = edge._1
    val right = edge._2
    val ltor = Math.abs(left)  + Math.abs(right - left)
    val rtol = Math.abs(right) + Math.abs(right - left)

    Math.min(ltor, rtol)
  })

  val length = if (lengths.length > 0) lengths.min else 0

  println(length)

}