fun ac105(args: Array<String>) {
    val (N, K) = args[0].split(" ").map { it.toInt() }
    val numList = args[1].split(" ").map { it.toInt() }
    var ans = Int.MAX_VALUE
    (0 until N + 1 - K).forEach { start ->
        val first = numList[start]
        val last = numList[start + K - 1]
        ans = Math.min(ans, when {
            last <= 0 -> Math.abs(first)
            first >= 0 -> Math.abs(last)
            else -> Math.abs(last - first) + Math.min(Math.abs(last), Math.abs(first))
        })
    }
    println(ans)
}

fun main(args: Array<String>) {
    ac105(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}