console.log((args=>{
  const [[N,k],x] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const K = k-1;
  let min = Infinity;
  for ( let i = 0; i+K < N; i++ ) {
    if ( x[i] < 0 && 0 < x[i+K] ) {
      min = Math.min( min, x[i+K] - x[i] + Math.min(x[i+K],-x[i]) );
    } else if ( x[i] >= 0 ) min = Math.min( min, x[i+K] );
    else if ( x[i+K] <= 0 ) min = Math.min( min, -x[i] );
  }
  return `${min}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
