import java.util.Collections

import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val line = StdIn.readLine.split(" ").map(s => s.toInt)
    val N = line(0)
    val K = line(1)
    val x = StdIn.readLine.split(" ").map(s => s.toInt)

    var left = 0
    var right = left
    var ans = Int.MaxValue
    while(left < N) {
      while(right < N && right - left < K) {
        right+=1
      }

      if (right - left == K) {
        val l = x(left)
        val r = x(right-1)

        val max = Math.max(l.abs, r.abs)
        val min = Math.min(l.abs, r.abs)

        if (l < 0 && 0 <= r) {
          ans = Math.min(ans, min * 2 + max)
        } else {
          ans = Math.min(ans, max)
        }
      }
      left+=1
    }

    println(ans)
  }
}
