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

*X,=list(map(int,input().split()))

A=[]

B=[]

for x in X:

    if x>=0:

        A.append(x)

    else:

        B.append(abs(x))

B.sort()

i=min(K,len(A))

j=K-i

ans=[]

while i>=0 and j<=len(B):

    if i==0:

        ans.append(B[j-1])

    elif j==0:

        ans.append(A[i-1])

    else:

        a,b=A[i-1],B[j-1]

        ans.append(a+b+min(a,b))

    i-=1

    j+=1

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

*X,=list(map(int,input().split()))

i=0

ans=[]

while i+K-1<N:

    a,b=X[i],X[i+K-1]

    if b<0:

        ans.append(abs(a))

    elif a>0:

        ans.append(b)

    else:

        a=abs(a)

        ans.append(a+b+min(a,b))

    i+=1

print((min(ans)))
N, K = list(map(int, input().split()))
(*X,) = list(map(int, input().split()))
A = []
B = []
for x in X:
    if x >= 0:
        A.append(x)
    else:
        B.append(abs(x))
B.sort()
i = min(K, len(A))
j = K - i
ans = []
while i >= 0 and j <= len(B):
    if i == 0:
        ans.append(B[j - 1])
    elif j == 0:
        ans.append(A[i - 1])
    else:
        a, b = A[i - 1], B[j - 1]
        ans.append(a + b + min(a, b))
    i -= 1
    j += 1
print((min(ans)))

N, K = list(map(int, input().split()))
(*X,) = list(map(int, input().split()))
i = 0
ans = []
while i + K - 1 < N:
    a, b = X[i], X[i + K - 1]
    if b < 0:
        ans.append(abs(a))
    elif a > 0:
        ans.append(b)
    else:
        a = abs(a)
        ans.append(a + b + min(a, b))
    i += 1
print((min(ans)))

-A = [] -B = [] -for x in X: -    if x >= 0: -        A.append(x) +i = 0 +ans = [] +while i + K - 1 < N: +    a, b = X[i], X[i + K - 1] +    if b < 0: +        ans.append(abs(a)) +    elif a > 0: +        ans.append(b) -        B.append(abs(x)) -B.sort() -i = min(K, len(A)) -j = K - i -ans = [] -while i >= 0 and j <= len(B): -    if i == 0: -        ans.append(B[j - 1]) -    elif j == 0: -        ans.append(A[i - 1]) -    else: -        a, b = A[i - 1], B[j - 1] +        a = abs(a) -    i -= 1 -    j += 1 +    i += 1