import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val x = new Array[Long](N)

  for(i <- 0 until N) {
    x(i) = in.next().toLong
  }


  //
  val x2 = x.filter(_ <= 0)
  var ans = Long.MaxValue

  if(x2.length >= K){
    val res = x2.reverse.apply(K-1)
    ans = -res
  }

  for(i <- 0 until N) {
    if(i + K - 1 < N) {
      if(x(i+K-1) >= 0){
        ans = Math.min(ans, x(i+K-1) - Math.min(0, x(i) * 2))
      }
    }
  }

  for(i <- 0 until N) {
    if(i + K - 1 < N) {
      if(x(i) <= 0){
        ans = Math.min(ans, Math.max(0, x(i+K-1) * 2) - x(i))
      }
    }
  }


  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
