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

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

pl, mi = 0, 0

recp, recm = [], []

for i in range(n):

    if x[i] >= 0:

        pl += 1

        recp.append(x[i])

    else:

        mi += 1

        recm.append(x[i])



num = float("inf")

recm = recm[:: -1]

for i in range(pl + 1):

    if i == 0:

        if k <= mi:

            num = min(num, abs(recm[k - 1]))

        else:

            continue

    else:

        if k - i == 0:

            num = min(num, recp[k - 1])

        elif 0 < k - i <= mi:

            num = min(num, recp[i - 1] + 2 * abs(recm[k - i - 1]))

            num = min(num, 2 * recp[i - 1] + abs(recm[k - i - 1]))



print(num)

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

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

num = float("inf")

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

    p = X[i]

    q = X[i + K - 1]

    if q < 0:

        num = min(num, abs(p))

    elif p < 0:

        num = min(num, abs(p) + 2 * abs(q))

        num = min(num, abs(p) * 2 + abs(q))

    else:

        num = min(num, q)



print(num)





n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
pl, mi = 0, 0
recp, recm = [], []
for i in range(n):
    if x[i] >= 0:
        pl += 1
        recp.append(x[i])
    else:
        mi += 1
        recm.append(x[i])
num = float("inf")
recm = recm[::-1]
for i in range(pl + 1):
    if i == 0:
        if k <= mi:
            num = min(num, abs(recm[k - 1]))
        else:
            continue
    else:
        if k - i == 0:
            num = min(num, recp[k - 1])
        elif 0 < k - i <= mi:
            num = min(num, recp[i - 1] + 2 * abs(recm[k - i - 1]))
            num = min(num, 2 * recp[i - 1] + abs(recm[k - i - 1]))
print(num)

N, K = list(map(int, input().split()))
X = list(map(int, input().split()))
num = float("inf")
for i in range(N - K + 1):
    p = X[i]
    q = X[i + K - 1]
    if q < 0:
        num = min(num, abs(p))
    elif p < 0:
        num = min(num, abs(p) + 2 * abs(q))
        num = min(num, abs(p) * 2 + abs(q))
    else:
        num = min(num, q)
print(num)

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -pl, mi = 0, 0 -recp, recm = [], [] -for i in range(n): -    if x[i] >= 0: -        pl += 1 -        recp.append(x[i]) +N, K = list(map(int, input().split())) +X = list(map(int, input().split())) +num = float("inf") +for i in range(N - K + 1): +    p = X[i] +    q = X[i + K - 1] +    if q < 0: +        num = min(num, abs(p)) +    elif p < 0: +        num = min(num, abs(p) + 2 * abs(q)) +        num = min(num, abs(p) * 2 + abs(q)) -        mi += 1 -        recm.append(x[i]) -num = float("inf") -recm = recm[::-1] -for i in range(pl + 1): -    if i == 0: -        if k <= mi: -            num = min(num, abs(recm[k - 1])) -        else: -            continue -    else: -        if k - i == 0: -            num = min(num, recp[k - 1]) -        elif 0 < k - i <= mi: -            num = min(num, recp[i - 1] + 2 * abs(recm[k - i - 1])) -            num = min(num, 2 * recp[i - 1] + abs(recm[k - i - 1])) +        num = min(num, q)