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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int k, int[] a) {
    long ans = long.max;
    for (int i = 0; i < a.length; i++) {
        if (i + k - 1 >= a.length) break;

        int lo = i;
        int hi = i + k - 1;
        // 0 -> lo -> hi の順に火をつける
        ans = min(ans, abs(a[lo]) + abs(a[hi] - a[lo]));
        // 0 -> hi -> lo の順に火をつける
        ans = min(ans, abs(a[hi]) + abs(a[hi] - a[lo]));
    }
    return ans;
}

void main() {
    auto nk = readints;
    int k = nk[1];
    auto a = readints;
    writeln(calc(k, a));
}
