import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln.split;
	auto N = tokens[0].to!uint;
	auto K = tokens[1].to!uint;
	auto x = my_readln.split.to!(long[]);

	long pos = N;
	foreach (i, e; x)
	{
		if (e >= 0)
		{
			pos = i;
			break;
		}
	}

	long begin = max(0, pos - K), end = min(pos + 1, N - K + 1);
	ulong ans = ulong.max;
	foreach (i; begin..end)
	{
		ulong l, r;
		if (x[i] < 0)	  l = abs(x[i]);
		if (x[i+K-1] > 0) r = x[i+K-1];
		ulong d = min(l, r) * 2 + max(l, r);
		ans = min(ans, d);
		//stderr.writeln(l, ":", r, " ", d);
	}
	
	writeln(ans);
	stdout.flush();
}