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

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



if x[0] >= 0:

    print((x[k - 1]))

    exit()

elif x[n - 1] < 0:

    print((abs(x[n - k])))

    exit()

else:

    for i in range(n):

        if x[i] >= 0:

            ori = i

            break



f_inf = float("inf")

res = f_inf

for i in range(max(ori - k, 0), min(ori + k, n) - k + 1):

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

    res = min(res, time)



print(res)

import sys



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

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



    if X[0] >= 0:

        print((X[k - 1]))

        exit()

    elif X[-1] < 0:

        print((abs(X[n - k])))

        exit()

    else:

        for i in range(n):

            if X[i] >= 0:

                ori = i

                break



    res = f_inf

    left = max(ori - k, 0)

    right = min(ori + k, n)

    for i in range(left, right - k + 1):

        RL = abs(X[i + k - 1] - X[i]) + abs(X[i + k - 1])

        LR = abs(X[i]) + abs(X[i + k - 1] - X[i])

        res = min(res, min(RL, LR))

    print(res)





if __name__ == '__main__':

    resolve()

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
if x[0] >= 0:
    print((x[k - 1]))
    exit()
elif x[n - 1] < 0:
    print((abs(x[n - k])))
    exit()
else:
    for i in range(n):
        if x[i] >= 0:
            ori = i
            break
f_inf = float("inf")
res = f_inf
for i in range(max(ori - k, 0), min(ori + k, n) - k + 1):
    time = min(
        abs(x[i + k - 1] - x[i]) + abs(x[i + k - 1]),
        abs(x[i]) + abs(x[i + k - 1] - x[i]),
    )
    res = min(res, time)
print(res)

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    X = list(map(int, input().split()))
    if X[0] >= 0:
        print((X[k - 1]))
        exit()
    elif X[-1] < 0:
        print((abs(X[n - k])))
        exit()
    else:
        for i in range(n):
            if X[i] >= 0:
                ori = i
                break
    res = f_inf
    left = max(ori - k, 0)
    right = min(ori + k, n)
    for i in range(left, right - k + 1):
        RL = abs(X[i + k - 1] - X[i]) + abs(X[i + k - 1])
        LR = abs(X[i]) + abs(X[i + k - 1] - X[i])
        res = min(res, min(RL, LR))
    print(res)


if __name__ == "__main__":
    resolve()

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -if x[0] >= 0: -    print((x[k - 1])) -    exit() -elif x[n - 1] < 0: -    print((abs(x[n - k]))) -    exit() -else: -    for i in range(n): -        if x[i] >= 0: -            ori = i -            break +import sys + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline -res = f_inf -for i in range(max(ori - k, 0), min(ori + k, n) - k + 1): -    time = min( -        abs(x[i + k - 1] - x[i]) + abs(x[i + k - 1]), -        abs(x[i]) + abs(x[i + k - 1] - x[i]), -    ) -    res = min(res, time) -print(res) +mod = 10**9 + 7 + + +def resolve(): +    n, k = list(map(int, input().split())) +    X = list(map(int, input().split())) +    if X[0] >= 0: +        print((X[k - 1])) +        exit() +    elif X[-1] < 0: +        print((abs(X[n - k]))) +        exit() +    else: +        for i in range(n): +            if X[i] >= 0: +                ori = i +                break +    res = f_inf +    left = max(ori - k, 0) +    right = min(ori + k, n) +    for i in range(left, right - k + 1): +        RL = abs(X[i + k - 1] - X[i]) + abs(X[i + k - 1]) +        LR = abs(X[i]) + abs(X[i + k - 1] - X[i]) +        res = min(res, min(RL, LR)) +    print(res) + + +if __name__ == "__main__": +    resolve()