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));

    /*
    int n = nk[0], k = nk[1];
    auto xs = readints;

    int[] pos, neg;
    foreach (x; xs) {
        if (x >= 0) pos ~= x;
        else neg ~= x;
    }
    neg.reverse();

    long ans = long.max;
    for (int i = 0; i < pos.length; i++) {
        long p = pos[i];

        int rest = k - i - 1;
        if (rest == 0) ans = min(ans, pos[i]);
        if (rest < 0) break;
        if (0 < rest && rest <= neg.length) {
            ans = min(ans, 2 * pos[i] + neg[rest-1] * -1);
        }
    }

    for (int i = 0; i < neg.length; i++) {
        int rest = k - i - 1;
        if (rest == 0) ans = min(ans, -neg[i]);
        if (rest < 0) break;
        if (0 < rest && rest <= pos.length) {
            ans = min(ans, 2 * -neg[i] + pos[rest-1]);
        }
    }

    writeln(ans);
    */
}
