import bisect



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

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



s = bisect.bisect_left(X,0)

if 0 in X:

    K -= 1

else:

    bisect.insort_left(X,0)

    N += 1



MIN = 2 * 10**9

for i in range(K+1):

    if s - K + i >= 0 and s + i <N:

        f = X[s -K+i]

        l = X[s+i]

        if abs(f) < abs(l):

            ans = abs(f) * 2 + abs(l)

        else:

            ans = abs(l) * 2 + abs(f)

        MIN =min(MIN,ans)



print(MIN)
def main():

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

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



    ans = 10**9



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

        t1 = abs(X[i]) + abs(X[i] - X[i+k-1])

        t2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1])

        t = min(t1,t2)



        ans = min(ans,t)



    print(ans)







main()
import bisect

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
s = bisect.bisect_left(X, 0)
if 0 in X:
    K -= 1
else:
    bisect.insort_left(X, 0)
    N += 1
MIN = 2 * 10**9
for i in range(K + 1):
    if s - K + i >= 0 and s + i < N:
        f = X[s - K + i]
        l = X[s + i]
        if abs(f) < abs(l):
            ans = abs(f) * 2 + abs(l)
        else:
            ans = abs(l) * 2 + abs(f)
        MIN = min(MIN, ans)
print(MIN)

def main():
    n, k = list(map(int, input().split()))
    X = list(map(int, input().split()))
    ans = 10**9
    for i in range(n - k + 1):
        t1 = abs(X[i]) + abs(X[i] - X[i + k - 1])
        t2 = abs(X[i + k - 1]) + abs(X[i] - X[i + k - 1])
        t = min(t1, t2)
        ans = min(ans, t)
    print(ans)


main()

-import bisect +def main(): +    n, k = list(map(int, input().split())) +    X = list(map(int, input().split())) +    ans = 10**9 +    for i in range(n - k + 1): +        t1 = abs(X[i]) + abs(X[i] - X[i + k - 1]) +        t2 = abs(X[i + k - 1]) + abs(X[i] - X[i + k - 1]) +        t = min(t1, t2) +        ans = min(ans, t) +    print(ans) -N, K = list(map(int, input().split())) -X = list(map(int, input().split())) -s = bisect.bisect_left(X, 0) -if 0 in X: -    K -= 1 -else: -    bisect.insort_left(X, 0) -    N += 1 -MIN = 2 * 10**9 -for i in range(K + 1): -    if s - K + i >= 0 and s + i < N: -        f = X[s - K + i] -        l = X[s + i] -        if abs(f) < abs(l): -            ans = abs(f) * 2 + abs(l) -        else: -            ans = abs(l) * 2 + abs(f) -        MIN = min(MIN, ans) -print(MIN) + +main()