import java.util.*

fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val candles = readLine()!!.split(" ").map { it.toLong() }

    var total = 0L
    for(i in (1 until k)) {
        total += candles[i] - candles[i-1]
    }
    var ans = total + Math.min(Math.abs(candles[0]), Math.abs(candles[k-1]))
    for(i in (1..n-k)) {
        total -= candles[i] - candles[i-1]
        total += candles[i+k-1] - candles[i-1+k-1]
        ans = Math.min(ans, total + Math.min(Math.abs(candles[i]), Math.abs(candles[i+k-1])))
    }
    println(ans)
}
