object Main extends App{
    val Array(n, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
   	val x = scala.io.StdIn.readLine.split(" ").map(_.toInt)

   	var ans = Int.MaxValue

   	for(i<-0 to n-k){
   		ans = math.min(ans, x(i).abs + (x(i+k-1) - x(i)).abs)
   		ans = math.min(ans, x(i+k-1).abs + (x(i) - x(i+k-1)).abs)
   	}

   	println(ans)

}
