import java.lang.Math.*

fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val x = readLine()!!.split(" ").map{ it.toLong() }
	
	var ans=Long.MAX_VALUE
	for(r in k-1..n-1){
		val l=r-k+1
		val lr=x[r]-x[l]
		ans=min(ans,lr+abs(x[l]))
		ans=min(ans,lr+abs(x[r]))
	}
	println(ans)
}