function main(input) {
  var ary = input.split("\n");
  var nums = ary[0].split(" ");
  var n = parseInt(nums[0], 10);
  var k = parseInt(nums[1], 10);
  var x = ary[1].split(" ").map(i => parseInt(i, 10));
  var minTime = null;

  for (var i = 0; i < n - k + 1; i++) {
    var time = calcMinTime(i, i + k - 1, x);
    if (minTime === null || time < minTime) {
      minTime = time;
    }
  }
  console.log(minTime);
}

function calcMinTime(i, j, x) {
  var a = Math.abs(x[i]) + Math.abs(x[j] - x[i]);
  var b = Math.abs(x[j]) + Math.abs(x[j] - x[i]);
  return Math.min(a, b);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
