import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val x = (0 until n).map { sc.next().toLong() }
    println(problem107c(n, k, x))
}

fun problem107c(n: Int, k: Int, x: List<Long>): Long {
    var min = Long.MAX_VALUE
    for (i in 0 .. n - k) {
        if (i < 0 && x[i + 1] < 0) continue
        if (i > 0 && x[i - 1] > 0) continue
//        debugLog(i, x[i], x[i + k - 1], Math.abs(x[i] - x[i + k - 1]) * 2, Math.abs(x[i] * 2 - x[i + k - 1]))
        if (x[i] > 0) {
            min = Math.min(min, x[i + k - 1])
            continue
        }
        if (x[i + k - 1] < 0) {
            min = Math.min(min, Math.abs(x[i]))
            continue
        }
        min = listOf(min, Math.abs(x[i] - x[i + k - 1] * 2), Math.abs(x[i] * 2 - x[i + k - 1])).min()!!
    }
    return min
}