import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, k) = (sc.nextInt, sc.nextInt)
  val xs = Vector.fill(n)(sc.nextInt)

  @tailrec
  def lp(as: Seq[Int], acc: Int): Int = {
    val x = as.take(k)
    if (x.length == k) {
      val d = x.last - x.head + (Math.abs(x.last) min Math.abs(x.head))
      lp(as.tail, acc min d)
    } else {
      acc
    }
  }

  println(lp(xs, Int.MaxValue))
}
