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

ary = [0] + list(map(int, input().split()))

ary.sort()

zero = ary.index(0)

a = [abs(i - zero) for i in range(N + 1)]

ary.pop(zero)

ans = float("Inf")

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

    b = N - i - 1

    d = abs(ary[i])

    if a[i] >= K:

        ans = min(ans, d)

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

    d = abs(ary[b])

    if a[b] >= K:

        ans = min(ans, d)

    ans = min(ans, d + abs(ary[b] - ary[b - K + 1]))

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

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

ary2 = sorted(ary+[0])

zero = ary2.index(0)

k = [abs(i - zero) if i < zero else ((i + 1) - zero)for i in range(N)]

ans = float("Inf")

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

    if k[i] <= K:

        if ans > abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)]):

            ans = abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)])

for i in range(N-1, K-2, -1):

    if k[i] <= K:

        if ans > abs(ary[i]) + abs(ary[i] - ary[i - (K-1)]):

            ans = abs(ary[i]) + abs(ary[i] - ary[i - (K-1)])

print(ans)

N, K = list(map(int, input().split()))
ary = [0] + list(map(int, input().split()))
ary.sort()
zero = ary.index(0)
a = [abs(i - zero) for i in range(N + 1)]
ary.pop(zero)
ans = float("Inf")
for i in range(N - K + 1):
    b = N - i - 1
    d = abs(ary[i])
    if a[i] >= K:
        ans = min(ans, d)
    ans = min(ans, d + abs(ary[i] - ary[i + K - 1]))
    d = abs(ary[b])
    if a[b] >= K:
        ans = min(ans, d)
    ans = min(ans, d + abs(ary[b] - ary[b - K + 1]))
print(ans)

N, K = list(map(int, input().split()))
ary = list(map(int, input().split()))
ary2 = sorted(ary + [0])
zero = ary2.index(0)
k = [abs(i - zero) if i < zero else ((i + 1) - zero) for i in range(N)]
ans = float("Inf")
for i in range(N - K + 1):
    if k[i] <= K:
        if ans > abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)]):
            ans = abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)])
for i in range(N - 1, K - 2, -1):
    if k[i] <= K:
        if ans > abs(ary[i]) + abs(ary[i] - ary[i - (K - 1)]):
            ans = abs(ary[i]) + abs(ary[i] - ary[i - (K - 1)])
print(ans)

-ary = [0] + list(map(int, input().split())) -ary.sort() -zero = ary.index(0) -a = [abs(i - zero) for i in range(N + 1)] -ary.pop(zero) +ary = list(map(int, input().split())) +ary2 = sorted(ary + [0]) +zero = ary2.index(0) +k = [abs(i - zero) if i < zero else ((i + 1) - zero) for i in range(N)] -    b = N - i - 1 -    d = abs(ary[i]) -    if a[i] >= K: -        ans = min(ans, d) -    ans = min(ans, d + abs(ary[i] - ary[i + K - 1])) -    d = abs(ary[b]) -    if a[b] >= K: -        ans = min(ans, d) -    ans = min(ans, d + abs(ary[b] - ary[b - K + 1])) +    if k[i] <= K: +        if ans > abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)]): +            ans = abs(ary[i]) + abs(ary[i] - ary[i + (K - 1)]) +for i in range(N - 1, K - 2, -1): +    if k[i] <= K: +        if ans > abs(ary[i]) + abs(ary[i] - ary[i - (K - 1)]): +            ans = abs(ary[i]) + abs(ary[i] - ary[i - (K - 1)])