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

fun abc107c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val xList = readLine()!!.split(" ").map { it.toLong() }

    val moveLength = (0..n - k).map {
        val right = xList[it + k - 1]
        val left = xList[it]
        val between = Math.abs(right - left)
        Math.min(Math.abs(left) + between, Math.abs(right) + between)
    }

    val answer = moveLength.min()

    println(answer)
}
