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

x=[int(i) for i in input().split()]

ans=10**9

A=[]

B=[]

for i in range(N):

    if x[i]>=0:

        A.append(x[i])

    else:

        B.append(-x[i])

B=B[::-1]

if len(A)>=K:

    ans=min([ans,A[K-1]])

if len(B)>=K:

    ans=min([ans,B[K-1]])

C=len(A)

D=len(B)

for i in range(1,K):

    if ((i-1)<C) and ((K-i-1)<D):

        tmp1=A[i-1]+2*B[K-i-1]

        tmp2=2*A[i-1]+B[K-i-1]

        ans=min([ans,tmp1,tmp2])

print(ans)

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

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

ans=10**9

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

    tmp1=abs(x[i])+abs(x[i]-x[i+K-1])

    tmp2=abs(x[i+K-1])+abs(x[i]-x[i+K-1])

    ans=min([ans,tmp1,tmp2])

print(ans)

N, K = list(map(int, input().split()))
x = [int(i) for i in input().split()]
ans = 10**9
A = []
B = []
for i in range(N):
    if x[i] >= 0:
        A.append(x[i])
    else:
        B.append(-x[i])
B = B[::-1]
if len(A) >= K:
    ans = min([ans, A[K - 1]])
if len(B) >= K:
    ans = min([ans, B[K - 1]])
C = len(A)
D = len(B)
for i in range(1, K):
    if ((i - 1) < C) and ((K - i - 1) < D):
        tmp1 = A[i - 1] + 2 * B[K - i - 1]
        tmp2 = 2 * A[i - 1] + B[K - i - 1]
        ans = min([ans, tmp1, tmp2])
print(ans)

N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**9
for i in range(N - K + 1):
    tmp1 = abs(x[i]) + abs(x[i] - x[i + K - 1])
    tmp2 = abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1])
    ans = min([ans, tmp1, tmp2])
print(ans)

-x = [int(i) for i in input().split()] +x = list(map(int, input().split())) -A = [] -B = [] -for i in range(N): -    if x[i] >= 0: -        A.append(x[i]) -    else: -        B.append(-x[i]) -B = B[::-1] -if len(A) >= K: -    ans = min([ans, A[K - 1]]) -if len(B) >= K: -    ans = min([ans, B[K - 1]]) -C = len(A) -D = len(B) -for i in range(1, K): -    if ((i - 1) < C) and ((K - i - 1) < D): -        tmp1 = A[i - 1] + 2 * B[K - i - 1] -        tmp2 = 2 * A[i - 1] + B[K - i - 1] -        ans = min([ans, tmp1, tmp2]) +for i in range(N - K + 1): +    tmp1 = abs(x[i]) + abs(x[i] - x[i + K - 1]) +    tmp2 = abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]) +    ans = min([ans, tmp1, tmp2])