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

void main() {
    auto tmp = readln.split.to!(long[]);
    auto N = tmp[0], K = tmp[1];
    auto xs = readln.split.to!(long[]);
    long minTime = long.max;
    foreach (i; 0..N-K+1) {
        auto j = i + K - 1;
        auto t = min(abs(xs[i]) + xs[j] - xs[i], abs(xs[j]) + xs[j] - xs[i]);
        if (t < minTime) minTime = t;
    }
    if (minTime == long.max) minTime = 0;
    writeln(minTime);
}

