unittest
{
	assert( [ "5 3", "-30 -10 10 20 50" ].solve == 40 );
	assert( [ "3 2", "10 20 30" ].solve == 20 );
	assert( [ "1 1", "0" ].solve == 0 );
	assert( [ "8 5", "-9 -7 -4 -3 1 2 3 4" ].solve == 10 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto xs = input.front.split.to!( long[] );
	
	auto ans = long.max;
	for( auto l = 0L, r = k - 1; r < xs.length; l++, r++ )
	{
		ans = min( ans, xs[ r ] - xs[ l ] + min( abs( xs[ l ] ), abs( xs[ r ] ) ) );
	}
	return ans;
}
