import java.math.*

fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map{it.toInt()}
    
    val xs = readInputLine().split(" ").map{it.toInt()}.toIntArray()
    
    var l = 0
    var r = K - 1
    
    var ans = distance(xs, l, r)

    while (r < N - 1) {
        l++
        r++
        val nextDistance = distance(xs, l, r)
        if (nextDistance < ans) {
            ans = nextDistance
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun distance(xs: IntArray, l: Int, r: Int): Int {
    return Math.min(Math.abs(xs[l]) + Math.abs(xs[r] - xs[l]), Math.abs(xs[r]) + Math.abs(xs[l] - xs[r]))
}
