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

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



min_t = 10 ** 9



import bisect



snuke = bisect.bisect_left(x, 0)

if snuke < n and x[snuke] == 0:

    k -= 1

    n -= 1

    del x[snuke]



for i in range(k+1):

    if i == 0:

        left = 0

    elif snuke - i >= 0:

        left = abs(x[snuke - i])

    else:

        left = 10 ** 9



    if k - i == 0:

        right = 0

    elif snuke + k - i - 1 <= n - 1:

        right = abs(x[snuke + k - i - 1])

    else:

        right = 10 ** 9



    min_t = min(min_t, min(left, right) * 2 + max(left, right))



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

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

a=[]

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

    l=x[i]

    r=x[i+k-1]

    a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))

print((min(a)))
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
min_t = 10**9
import bisect

snuke = bisect.bisect_left(x, 0)
if snuke < n and x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]
for i in range(k + 1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10**9
    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10**9
    min_t = min(min_t, min(left, right) * 2 + max(left, right))
print(min_t)

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

-x = list(map(int, input().split())) -min_t = 10**9 -import bisect - -snuke = bisect.bisect_left(x, 0) -if snuke < n and x[snuke] == 0: -    k -= 1 -    n -= 1 -    del x[snuke] -for i in range(k + 1): -    if i == 0: -        left = 0 -    elif snuke - i >= 0: -        left = abs(x[snuke - i]) -    else: -        left = 10**9 -    if k - i == 0: -        right = 0 -    elif snuke + k - i - 1 <= n - 1: -        right = abs(x[snuke + k - i - 1]) -    else: -        right = 10**9 -    min_t = min(min_t, min(left, right) * 2 + max(left, right)) -print(min_t) +x = sorted(list(map(int, input().split()))) +a = [] +for i in range(n - k + 1): +    l = x[i] +    r = x[i + k - 1] +    a.append(min(abs(l) + abs(r - l), abs(r) + abs(l - r))) +print((min(a)))