import numpy as np

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

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

arr = X[K - 1:] - X[:-K + 1]

arr1 = arr + np.abs(X[:-K + 1])

arr2 = arr + np.abs(X[K - 1:])

if len(arr) == 0:

    print((0))

else:

    ans = min(arr1.min(), arr2.min())

    print(ans)

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

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



ans = 10**18

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

    d1 = X[i + K - 1] - X[i] + abs(X[i])

    d2 = X[i + K - 1] - X[i] + abs(X[i + K - 1])

    # print('d', d)

    ans = min(ans, d1, d2)

print(ans)

import numpy as np

N, K = list(map(int, input().split()))
X = np.array(list(map(int, input().split())))
arr = X[K - 1 :] - X[: -K + 1]
arr1 = arr + np.abs(X[: -K + 1])
arr2 = arr + np.abs(X[K - 1 :])
if len(arr) == 0:
    print((0))
else:
    ans = min(arr1.min(), arr2.min())
    print(ans)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
ans = 10**18
for i in range(N - K + 1):
    d1 = X[i + K - 1] - X[i] + abs(X[i])
    d2 = X[i + K - 1] - X[i] + abs(X[i + K - 1])
    # print('d', d)
    ans = min(ans, d1, d2)
print(ans)

-import numpy as np - -X = np.array(list(map(int, input().split()))) -arr = X[K - 1 :] - X[: -K + 1] -arr1 = arr + np.abs(X[: -K + 1]) -arr2 = arr + np.abs(X[K - 1 :]) -if len(arr) == 0: -    print((0)) -else: -    ans = min(arr1.min(), arr2.min()) -    print(ans) +X = list(map(int, input().split())) +ans = 10**18 +for i in range(N - K + 1): +    d1 = X[i + K - 1] - X[i] + abs(X[i]) +    d2 = X[i + K - 1] - X[i] + abs(X[i + K - 1]) +    # print('d', d) +    ans = min(ans, d1, d2) +print(ans)