fun main(args: Array<String>) {
    var (N, K) = readLine()!!.split(" ").map(String::toInt)
    val xx = readLine()!!.split(" ").map(String::toInt)
    var pos = mutableListOf<Int>()
    var neg = mutableListOf<Int>()
    for (x in xx) {
        when {
            x == 0 -> K--
            x > 0 -> pos.add(x)
            else -> neg.add(-x)
        }
    }
    if (K == 0) {
        println(0)
        return
    }
    neg.reverse()
    var ans = 1 shl 29
    for (i in 0 until pos.size) {
        val d = pos[i]
        val rest = K - (i + 1)
        if (rest < 0) break
        if (rest == 0) ans = Math.min(ans, d)
        else if (rest <= neg.size) {
            ans = Math.min(ans, d * 2 + neg[rest-1])
        }
    }
    var tmp = pos; pos = neg; neg = tmp;
    for (i in 0 until pos.size) {
        val d = pos[i]
        val rest = K - (i + 1)
        if (rest < 0) break
        if (rest == 0) ans = Math.min(ans, d)
        else if (rest <= neg.size) {
            ans = Math.min(ans, d * 2 + neg[rest-1])
        }
    }
    println(ans)
}