if __name__ == "__main__":

    N, K = list(map(int, input().split()))

    x = list(map(int, input().split()))



    ans = 10 ** 10

    for i in range(N-K+1):

        L = x[i]

        R = x[i+K-1]

        if L <= 0 and R <= 0:

            tmp = abs(L)

        elif L >= 0 and R >= 0:

            tmp = R

        else:

            tmp = abs(L) + (R-L)

            if tmp > 2 * R + abs(L):

                tmp = 2 * R + abs(L)

        if tmp < ans:

            ans = tmp

    print(ans)

if __name__ == "__main__":

    n, k = list(map(int, input().split()))

    x = list(map(int, input().split()))



    x.sort()

    xmin = x[0]

    xmax = x[k-1]



    ans = 0

    if xmin < 0 and xmax >= 0:

        ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])

    else:

        ans = max([abs(xmin), abs(xmax)])



    for i in range(n - k + 1):

        xmin = x[i]

        xmax = x[i + k - 1]

        if xmin < 0 and xmax >= 0:

            tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])

        else:

            tmp = max([abs(xmin), abs(xmax)])

        if tmp < ans:

            ans = tmp



    print(ans)

if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = 10**10
    for i in range(N - K + 1):
        L = x[i]
        R = x[i + K - 1]
        if L <= 0 and R <= 0:
            tmp = abs(L)
        elif L >= 0 and R >= 0:
            tmp = R
        else:
            tmp = abs(L) + (R - L)
            if tmp > 2 * R + abs(L):
                tmp = 2 * R + abs(L)
        if tmp < ans:
            ans = tmp
    print(ans)

if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    x.sort()
    xmin = x[0]
    xmax = x[k - 1]
    ans = 0
    if xmin < 0 and xmax >= 0:
        ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
    else:
        ans = max([abs(xmin), abs(xmax)])
    for i in range(n - k + 1):
        xmin = x[i]
        xmax = x[i + k - 1]
        if xmin < 0 and xmax >= 0:
            tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)])
        else:
            tmp = max([abs(xmin), abs(xmax)])
        if tmp < ans:
            ans = tmp
    print(ans)

-    N, K = list(map(int, input().split())) +    n, k = list(map(int, input().split())) -    ans = 10**10 -    for i in range(N - K + 1): -        L = x[i] -        R = x[i + K - 1] -        if L <= 0 and R <= 0: -            tmp = abs(L) -        elif L >= 0 and R >= 0: -            tmp = R +    x.sort() +    xmin = x[0] +    xmax = x[k - 1] +    ans = 0 +    if xmin < 0 and xmax >= 0: +        ans = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)]) +    else: +        ans = max([abs(xmin), abs(xmax)]) +    for i in range(n - k + 1): +        xmin = x[i] +        xmax = x[i + k - 1] +        if xmin < 0 and xmax >= 0: +            tmp = min([abs(xmin), abs(xmax)]) * 2 + max([abs(xmin), abs(xmax)]) -            tmp = abs(L) + (R - L) -            if tmp > 2 * R + abs(L): -                tmp = 2 * R + abs(L) +            tmp = max([abs(xmin), abs(xmax)])