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

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

num = 1000000000





def cal_num(a, b):

    if x[a] * x[b] < 0:

        return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b]))

    else:

        return max(abs(x[a]), abs(x[b]))



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

    c = cal_num(i, i+k-1)

    if num >= c:

        num = c



print(num)

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



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



if k == 1:

    min_num = 10**20

    for i in x:

        if abs(i) < min_num:

            min_num = abs(i)

    print(min_num)

    exit()



min_dist = 10**20



dist = 0



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

    dist = (x[i+k-1] - x[i])

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

    if dist < min_dist:

        min_dist = dist



print(min_dist)
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
num = 1000000000


def cal_num(a, b):
    if x[a] * x[b] < 0:
        return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b]))
    else:
        return max(abs(x[a]), abs(x[b]))


for i in range(n - k + 1):
    c = cal_num(i, i + k - 1)
    if num >= c:
        num = c
print(num)

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
if k == 1:
    min_num = 10**20
    for i in x:
        if abs(i) < min_num:
            min_num = abs(i)
    print(min_num)
    exit()
min_dist = 10**20
dist = 0
for i in range(n - k + 1):
    dist = x[i + k - 1] - x[i]
    dist += min(abs(x[i + k - 1]), abs(x[i]))
    if dist < min_dist:
        min_dist = dist
print(min_dist)

-num = 1000000000 - - -def cal_num(a, b): -    if x[a] * x[b] < 0: -        return min(abs(x[a]), abs(x[b])) * 2 + max(abs(x[a]), abs(x[b])) -    else: -        return max(abs(x[a]), abs(x[b])) - - +if k == 1: +    min_num = 10**20 +    for i in x: +        if abs(i) < min_num: +            min_num = abs(i) +    print(min_num) +    exit() +min_dist = 10**20 +dist = 0 -    c = cal_num(i, i + k - 1) -    if num >= c: -        num = c -print(num) +    dist = x[i + k - 1] - x[i] +    dist += min(abs(x[i + k - 1]), abs(x[i])) +    if dist < min_dist: +        min_dist = dist +print(min_dist)