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

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



if N == 1:

    print((abs(X[0])))

    exit()





flg = False



for x in X:

    if x < 0:

        flg = True



if flg is False:

    print((X[K - 1]))

    exit()



flag2 = False



for x in X:

    if x > 0:

        flag2 = True



if flag2 is False:

    X.reverse()

    print((abs(X[K - 1])))

    exit()





def sol(lft, rgt):

    if X[lft] < 0 and X[rgt] < 0:

        return float('inf')

    elif X[lft] <= 0:

        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])

    else:

        return float('inf')





lft, rgt = 0, 0

ans = float('inf')

while True:



    if rgt == N - 1:

        break



    if rgt - lft + 1 < K:

        rgt += 1

        if rgt - lft + 1 == K:

            ans = min(ans, sol(lft, rgt))

            lft += 1

print(ans)

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

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



lft, rgt = 0, K - 1

ans = float('inf')



while True:

    if rgt == N:

        break

    ans = min(ans, min(abs(X[lft]) + abs(X[lft] - X[rgt]),

                       abs(X[rgt]) + abs(X[rgt] - X[lft])))

    lft += 1

    rgt += 1

print(ans)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
if N == 1:
    print((abs(X[0])))
    exit()
flg = False
for x in X:
    if x < 0:
        flg = True
if flg is False:
    print((X[K - 1]))
    exit()
flag2 = False
for x in X:
    if x > 0:
        flag2 = True
if flag2 is False:
    X.reverse()
    print((abs(X[K - 1])))
    exit()


def sol(lft, rgt):
    if X[lft] < 0 and X[rgt] < 0:
        return float("inf")
    elif X[lft] <= 0:
        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])
    else:
        return float("inf")


lft, rgt = 0, 0
ans = float("inf")
while True:
    if rgt == N - 1:
        break
    if rgt - lft + 1 < K:
        rgt += 1
        if rgt - lft + 1 == K:
            ans = min(ans, sol(lft, rgt))
            lft += 1
print(ans)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
lft, rgt = 0, K - 1
ans = float("inf")
while True:
    if rgt == N:
        break
    ans = min(
        ans, min(abs(X[lft]) + abs(X[lft] - X[rgt]), abs(X[rgt]) + abs(X[rgt] - X[lft]))
    )
    lft += 1
    rgt += 1
print(ans)

-if N == 1: -    print((abs(X[0]))) -    exit() -flg = False -for x in X: -    if x < 0: -        flg = True -if flg is False: -    print((X[K - 1])) -    exit() -flag2 = False -for x in X: -    if x > 0: -        flag2 = True -if flag2 is False: -    X.reverse() -    print((abs(X[K - 1]))) -    exit() - - -def sol(lft, rgt): -    if X[lft] < 0 and X[rgt] < 0: -        return float("inf") -    elif X[lft] <= 0: -        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt]) -    else: -        return float("inf") - - -lft, rgt = 0, 0 +lft, rgt = 0, K - 1 -    if rgt == N - 1: +    if rgt == N: -    if rgt - lft + 1 < K: -        rgt += 1 -        if rgt - lft + 1 == K: -            ans = min(ans, sol(lft, rgt)) -            lft += 1 +    ans = min( +        ans, min(abs(X[lft]) + abs(X[lft] - X[rgt]), abs(X[rgt]) + abs(X[rgt] - X[lft])) +    ) +    lft += 1 +    rgt += 1