// 与えられたXの部分配列を用意、距離の値を算出
//それだと
// 最大でN^2になるナ10^2^5=10^10で確実に死ぬ
//k*(n-k)でkはn以下という制約があるので死ぬとは限らんな

function get_run_length(xs){
  const max = xs[xs.length-1];
  const min=xs[0]
  var result = 0;

  if(max > min*-1){
    result = min*-2 + max;
  }else{
    result = min*-1 + max*2;
  }

  if(min>=0){result = max;}
  if(max<=0){result = min*-1;}

  return result;
}

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0].split(' ')[0]);
  const K = parseInt(lines[0].split(' ')[1]);
  const Xs = lines[1].split(' ').map(x => parseInt(x))

  var result = 1000000;
  for(var i=0;i<N-K+1;i++){
    var part_xs = Xs.slice(i,i+K)
   var tmp = get_run_length(part_xs);
    result = Math.min(tmp, result);
//    console.log([i,result]);
  }

  if(result==0){result=0;}
  console.log(result);
}


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