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

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

XR = [x if x > 0 else x * 2 for x in X]

XL = [x * 2 if x > 0 else x for x in X]



ans = 10**9

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

  dist_R = XR[i] - min(0, XR[i-k+1])

  dist_L = max(0, XL[i]) - XL[i-k+1]

  #print(i, dist_R, dist_L)

  ans = min(ans, dist_R, dist_L)

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

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

ans = 10**9

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

  dR = abs(x[i]) + abs(x[i] - x[i-k+1])

  dL = abs(x[i-k+1]) + abs(x[i] - x[i-k+1])

  ans = min(ans, dR, dL)

print(ans)
n, k = list(map(int, input().split()))
X = list(map(int, input().split()))
XR = [x if x > 0 else x * 2 for x in X]
XL = [x * 2 if x > 0 else x for x in X]
ans = 10**9
for i in range(k - 1, n):
    dist_R = XR[i] - min(0, XR[i - k + 1])
    dist_L = max(0, XL[i]) - XL[i - k + 1]
    # print(i, dist_R, dist_L)
    ans = min(ans, dist_R, dist_L)
print(ans)

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**9
for i in range(k - 1, n):
    dR = abs(x[i]) + abs(x[i] - x[i - k + 1])
    dL = abs(x[i - k + 1]) + abs(x[i] - x[i - k + 1])
    ans = min(ans, dR, dL)
print(ans)

-X = list(map(int, input().split())) -XR = [x if x > 0 else x * 2 for x in X] -XL = [x * 2 if x > 0 else x for x in X] +x = list(map(int, input().split())) -    dist_R = XR[i] - min(0, XR[i - k + 1]) -    dist_L = max(0, XL[i]) - XL[i - k + 1] -    # print(i, dist_R, dist_L) -    ans = min(ans, dist_R, dist_L) +    dR = abs(x[i]) + abs(x[i] - x[i - k + 1]) +    dL = abs(x[i - k + 1]) + abs(x[i] - x[i - k + 1]) +    ans = min(ans, dR, dL)