import java.util.Scanner


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    val xs = new Array[Int](n)
    
    for (i <- xs.indices) {
      xs(i) = sc.nextInt()
    }
    
    var ans = 1000000000
    
    for (i <- 0 until n - k + 1) {
      val y = xs(i)
      val z = xs(i + k - 1)
      val distance = math.abs(z - y)
      if (math.min(y, z) > 0) {
        ans = math.min(ans, distance + math.min(y, z))
      } else if (math.max(y, z) < 0) {
        ans = math.min(ans, distance - math.max(y, z))
      } else {
        val m = math.min(math.abs(y), math.abs(z))
        ans = math.min(ans, distance + m)
      }
    }
    
    println(ans)
  }
  
  def printArray[T](arr: Array[T]): Unit = {
    for (i <- arr.indices) {
      print(s"${arr(i)} ")
    }
    println()
  }
}
