fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    lateinit var dfs: (v: Int, p: Int) -> Unit

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val x = Array(N) { sc.next().toLong() }
        val xl = listOf(0L) + x.filter { it < 0 }.map { -it }.sorted().take(K)
        val xr = listOf(0L) + x.filter { it >= 0 }.take(K)
        val ans = mutableListOf<Long>()
        for (i in 0..K) {
            if (i < xr.count() && K - i < xl.count()) {
                val a1 = xl[K - i]
                val a2 = xr[i]
                ans += a1 * 2 + a2
                ans += a1 + a2 * 2
            }
        }
        pw.println(ans.min()!!)
    }
}
