import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

import scala.annotation.tailrec

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val Array(n, k) = input.nextLine().split(" ").map(_.toInt)
      val xs = input.nextLine().split(" ").map(_.toInt)

      output.println(0.to(n - k).map { i =>
        val l = xs(i)
        val r = xs(i + k - 1)
        // output.println(l, r)
        (Math.abs(l) + Math.abs(r - l)).min(Math.abs(r) + Math.abs(r -  l))
      }.min)
    }


    @tailrec
    final def gcd(m: Int, n: Int): Int = {
      val (x, y) = if (m > n) (m, n) else (n, m)
      if (y != 0) gcd(y, x % y)
      else x
    }

  }

}
