fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val x = readLine()!!.split(" ").map(String::toInt)
    var ans = 1 shl 29
    for (i in 0 until N-K+1) {
        val l = Math.abs(x[i])
        val r = Math.abs(x[i+K-1])
        val d = Math.abs(x[i+K-1] - x[i])
        ans = Math.min(ans, l + d)
        ans = Math.min(ans, r + d)
    }
    println(ans)
}