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



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto xs = input.front.split.to!( long[] );
	
	return tuple( nk[ 1 ], xs );
}

auto solve( long k, long[] xs )
{
	auto d = long.max;
	
	// 連続したロウソクK本を取るパターンを全検索
	for( auto i = 0; i + k <= xs.length; i++ )
	{
		auto ss = xs[ i .. i + k ];
		
		// 座標 0 から端のロウソクまでの距離
		auto db = min( ss[ 0 ].abs, ss[ $ - 1 ].abs );
		
		// 全ロウソク間の距離
		auto dm = ( ss[ 0 ] - ss[ $ - 1 ] ).abs;
		
		// 最短距離を取る
		d = min( d, dm + db );
	}
	
	return d;
}
