import numpy as np

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

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

idx = np.searchsorted(X, 0)

# print('idx', idx)

ans = 10**10

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

    l = i

    r = i + K - 1

    d1 = np.abs(X[l]) + np.abs(X[r] - X[l])

    d2 = np.abs(X[r]) + np.abs(X[r] - X[l])

    d = min(d1, d2)

    ans = min(ans, d)

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)

import numpy as np

N, K = list(map(int, input().split()))
X = np.array(list(map(int, input().split())))
idx = np.searchsorted(X, 0)
# print('idx', idx)
ans = 10**10
for i in range(N - K + 1):
    l = i
    r = i + K - 1
    d1 = np.abs(X[l]) + np.abs(X[r] - X[l])
    d2 = np.abs(X[r]) + np.abs(X[r] - X[l])
    d = min(d1, d2)
    ans = min(ans, d)
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)

-idx = np.searchsorted(X, 0) -# print('idx', idx) -ans = 10**10 -for i in range(N - K + 1): -    l = i -    r = i + K - 1 -    d1 = np.abs(X[l]) + np.abs(X[r] - X[l]) -    d2 = np.abs(X[r]) + np.abs(X[r] - X[l]) -    d = min(d1, d2) -    ans = min(ans, d) -print(ans) +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)