"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nk = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nk[0], K = nk[1];
    let X = lines.shift().split(/\s/).map((v) => v - 0);
let ans = 1e9;
    for (let i = 0; i < N - K+1; i++) {
       let a = Math.abs(X[i]) + X[i+K-1] - X[i];
       let b = Math.abs(X[i+K-1]) + X[i+K-1] - X[i];
      ans = Math.min(...[ans, a, b]);
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));