import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container, std.typecons;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int[] x = new int[n];
	foreach (i; 0..n) scanf("%d", &x[i]);
	int c = x.assumeSorted.lowerBound(0).length.to!int;
	int ans = 1<<30;
	foreach (i; 0..c+1) {
		if (i+k > n) break;
		int l = 0, r = 0;
		if (i != c) {
			if (c-i > k) continue;
			l = -x[i];
		}
		r = max(0, x[i+k-1]);
		ans = min(ans, l*2+r);
		ans = min(ans, l+r*2);
	}
	writeln(ans);
}