// C - Candles
// https://abc107.contest.atcoder.jp/tasks/arc101_a

import scala.io.StdIn.readLine
import math.{min, abs}

object Main extends App {

  val Array(n, k) = readLine.split(" ").map(_.toInt)
  val xs: Array[Int] = readLine.split(" ").map(_.toInt)

  case class Pair(head: Int, last: Int)
  val pairs: List[Pair] = (0 to n-k).toList.map(i => Pair(xs(i), xs(i+k-1)))
  val lengths = pairs.map(p => p.last - p.head + min(abs(p.head), abs(p.last)))

  println(lengths.min)

}