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

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

ans = float('inf')

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

    if x_ls[i+k-1] < 0:

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

    elif x_ls[i] < 0 and x_ls[i+k-1] >= 0:

        near = min(abs(x_ls[i]),abs(x_ls[i+k-1]))

        far = max(abs(x_ls[i]),abs(x_ls[i+k-1]))

        ans = min(ans, 2 * near + far)

    elif x_ls[i] >= 0:

        ans = min(ans, x_ls[i+k-1])

print(ans)
import sys

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

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

x_ls.sort()

if x_ls[0] >= 0:

    print((x_ls[k-1]))

    sys.exit()

elif x_ls[-1] <= 0:

    x_ls.sort(reverse=True)

    print((abs(x_ls[k-1])))

    sys.exit()

l = 0

r = k - 1

ans = float('inf')

while r < n:

    cost_1 = 2*abs(x_ls[l]) + abs(x_ls[r])

    cost_2 = abs(x_ls[l]) + 2*abs(x_ls[r])

    cost = min(cost_1,cost_2)

    ans = min(cost, ans)

    r += 1

    l += 1

print(ans)

    
n, k = list(map(int, input().split()))
x_ls = list(map(int, input().split()))
ans = float("inf")
for i in range(n - k + 1):
    if x_ls[i + k - 1] < 0:
        ans = min(ans, abs(x_ls[i]))
    elif x_ls[i] < 0 and x_ls[i + k - 1] >= 0:
        near = min(abs(x_ls[i]), abs(x_ls[i + k - 1]))
        far = max(abs(x_ls[i]), abs(x_ls[i + k - 1]))
        ans = min(ans, 2 * near + far)
    elif x_ls[i] >= 0:
        ans = min(ans, x_ls[i + k - 1])
print(ans)

import sys

n, k = list(map(int, input().split()))
x_ls = list(map(int, input().split()))
x_ls.sort()
if x_ls[0] >= 0:
    print((x_ls[k - 1]))
    sys.exit()
elif x_ls[-1] <= 0:
    x_ls.sort(reverse=True)
    print((abs(x_ls[k - 1])))
    sys.exit()
l = 0
r = k - 1
ans = float("inf")
while r < n:
    cost_1 = 2 * abs(x_ls[l]) + abs(x_ls[r])
    cost_2 = abs(x_ls[l]) + 2 * abs(x_ls[r])
    cost = min(cost_1, cost_2)
    ans = min(cost, ans)
    r += 1
    l += 1
print(ans)

+import sys + +x_ls.sort() +if x_ls[0] >= 0: +    print((x_ls[k - 1])) +    sys.exit() +elif x_ls[-1] <= 0: +    x_ls.sort(reverse=True) +    print((abs(x_ls[k - 1]))) +    sys.exit() +l = 0 +r = k - 1 -for i in range(n - k + 1): -    if x_ls[i + k - 1] < 0: -        ans = min(ans, abs(x_ls[i])) -    elif x_ls[i] < 0 and x_ls[i + k - 1] >= 0: -        near = min(abs(x_ls[i]), abs(x_ls[i + k - 1])) -        far = max(abs(x_ls[i]), abs(x_ls[i + k - 1])) -        ans = min(ans, 2 * near + far) -    elif x_ls[i] >= 0: -        ans = min(ans, x_ls[i + k - 1]) +while r < n: +    cost_1 = 2 * abs(x_ls[l]) + abs(x_ls[r]) +    cost_2 = abs(x_ls[l]) + 2 * abs(x_ls[r]) +    cost = min(cost_1, cost_2) +    ans = min(cost, ans) +    r += 1 +    l += 1