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

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



arr = []

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

    arr.append(min((abs(x[i])+abs(x[i]-x[i+k-1])), abs(x[i+k-1])+abs(x[i]-x[i+k-1])))



print((min(arr)))

import sys

stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)



i_i = lambda: int(i_s())

i_l = lambda: list(map(int, stdin.readline().split()))

i_s = lambda: stdin.readline().rstrip()



N, K = i_l()

x = i_l()



ans = 1 << 31

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

    if x[i] >= 0:

        ans = min(ans, x[i+K-1])

    elif x[i+K-1] <= 0:

        ans = min(ans, abs(x[i]))

    elif x[i] <= 0 and 0 <= x[i+K-1]:

        ans = min(ans, x[i+K-1] - x[i] + min(abs(x[i+K-1]), abs(x[i])))



print(ans)
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
arr = []
for i in range(n - k + 1):
    arr.append(
        min(
            (abs(x[i]) + abs(x[i] - x[i + k - 1])),
            abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]),
        )
    )
print((min(arr)))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
N, K = i_l()
x = i_l()
ans = 1 << 31
for i in range(N - K + 1):
    if x[i] >= 0:
        ans = min(ans, x[i + K - 1])
    elif x[i + K - 1] <= 0:
        ans = min(ans, abs(x[i]))
    elif x[i] <= 0 and 0 <= x[i + K - 1]:
        ans = min(ans, x[i + K - 1] - x[i] + min(abs(x[i + K - 1]), abs(x[i])))
print(ans)

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -arr = [] -for i in range(n - k + 1): -    arr.append( -        min( -            (abs(x[i]) + abs(x[i] - x[i + k - 1])), -            abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]), -        ) -    ) -print((min(arr))) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**7) +i_i = lambda: int(i_s()) +i_l = lambda: list(map(int, stdin.readline().split())) +i_s = lambda: stdin.readline().rstrip() +N, K = i_l() +x = i_l() +ans = 1 << 31 +for i in range(N - K + 1): +    if x[i] >= 0: +        ans = min(ans, x[i + K - 1]) +    elif x[i + K - 1] <= 0: +        ans = min(ans, abs(x[i])) +    elif x[i] <= 0 and 0 <= x[i + K - 1]: +        ans = min(ans, x[i + K - 1] - x[i] + min(abs(x[i + K - 1]), abs(x[i]))) +print(ans)