var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var nk = toIntArr(input[0].split(' '));
	var n = nk[0];
	var k = nk[1];
	var xs = toIntArr(input[1].split(' '));

	var s = n-k;
	var ans = Infinity;
	var L,R;
	var temp;
	for(var i = 0; i <= s; i++){
		L = xs[i];
		R = xs[i+k-1];
		if(R<0){
			temp = -L;
		}else if(L>0){
			temp = R;
		}else{
			temp = min(2*R-L,R-2*L);
		}
		ans = min(ans,temp);
	}
	console.log(ans);
}