# sys.stdin.readline()

import sys

input = sys.stdin.readline



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

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



x_p = [0] + [p for p in x if p > 0]#正

x_z = x.count(0)#0

x_n = [(-1) * ng for ng in x if ng < 0]#負

x_n = [0] + sorted(x_n)#0から始まる絶対値



myK = k - x_z#左右に移動して点火するろうそく数



if myK <= 0:

    print((0))

else:

    ans = float('inf')

    for i in range(myK + 1):

        if 0 <= i < len(x_p) and 0 <= myK - i < len(x_n):

            ans = min(ans, x_p[i] + x_n[myK - i] + min(x_p[i], x_n[myK - i]))

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

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



ans = float('inf')

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

    ans = min(

            ans,

            abs(x[i]) + abs(x[i + k - 1] - x[i]),

            abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i])

        )

print(ans)
# sys.stdin.readline()
import sys

input = sys.stdin.readline
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
x_p = [0] + [p for p in x if p > 0]  # 正
x_z = x.count(0)  # 0
x_n = [(-1) * ng for ng in x if ng < 0]  # 負
x_n = [0] + sorted(x_n)  # 0から始まる絶対値
myK = k - x_z  # 左右に移動して点火するろうそく数
if myK <= 0:
    print((0))
else:
    ans = float("inf")
    for i in range(myK + 1):
        if 0 <= i < len(x_p) and 0 <= myK - i < len(x_n):
            ans = min(ans, x_p[i] + x_n[myK - i] + min(x_p[i], x_n[myK - i]))
    print(ans)

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = float("inf")
for i in range(n - k + 1):
    ans = min(
        ans,
        abs(x[i]) + abs(x[i + k - 1] - x[i]),
        abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]),
    )
print(ans)

-# sys.stdin.readline() -import sys - -input = sys.stdin.readline -x_p = [0] + [p for p in x if p > 0]  # 正 -x_z = x.count(0)  # 0 -x_n = [(-1) * ng for ng in x if ng < 0]  # 負 -x_n = [0] + sorted(x_n)  # 0から始まる絶対値 -myK = k - x_z  # 左右に移動して点火するろうそく数 -if myK <= 0: -    print((0)) -else: -    ans = float("inf") -    for i in range(myK + 1): -        if 0 <= i < len(x_p) and 0 <= myK - i < len(x_n): -            ans = min(ans, x_p[i] + x_n[myK - i] + min(x_p[i], x_n[myK - i])) -    print(ans) +ans = float("inf") +for i in range(n - k + 1): +    ans = min( +        ans, +        abs(x[i]) + abs(x[i + k - 1] - x[i]), +        abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]), +    ) +print(ans)