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

X = [int(x) for x in input().split()]



import bisect

zero = bisect.bisect_left(X, 0)



left = max(zero - K, 0)

ans = float('inf')

while 1:

    right = left+K-1

    if left > zero + 1 or len(X) <= right: break

    lv, rv = X[left], X[right]

    if lv * rv > 0:

        ans = min(ans, max(abs(rv), abs(lv)))

    else:

        ans = min(ans, min(rv*2 - lv, rv - lv*2))

    left += 1



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

X = [int(x) for x in input().split()]



ans = float('inf')

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

    lv, rv = X[left], X[left+K-1]

    if lv * rv > 0:

        ans = min(ans, max(abs(rv), abs(lv)))

    else:

        ans = min(ans, min(rv*2 - lv, rv - lv*2))

print(ans)
N, K = list(map(int, input().split()))
X = [int(x) for x in input().split()]
import bisect

zero = bisect.bisect_left(X, 0)
left = max(zero - K, 0)
ans = float("inf")
while 1:
    right = left + K - 1
    if left > zero + 1 or len(X) <= right:
        break
    lv, rv = X[left], X[right]
    if lv * rv > 0:
        ans = min(ans, max(abs(rv), abs(lv)))
    else:
        ans = min(ans, min(rv * 2 - lv, rv - lv * 2))
    left += 1
print(ans)

N, K = list(map(int, input().split()))
X = [int(x) for x in input().split()]
ans = float("inf")
for left in range(N - K + 1):
    lv, rv = X[left], X[left + K - 1]
    if lv * rv > 0:
        ans = min(ans, max(abs(rv), abs(lv)))
    else:
        ans = min(ans, min(rv * 2 - lv, rv - lv * 2))
print(ans)

-import bisect - -zero = bisect.bisect_left(X, 0) -left = max(zero - K, 0) -while 1: -    right = left + K - 1 -    if left > zero + 1 or len(X) <= right: -        break -    lv, rv = X[left], X[right] +for left in range(N - K + 1): +    lv, rv = X[left], X[left + K - 1] -    left += 1