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

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

ans = 10 ** 10

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

    l, r = a[i], a[i + k -1]

    time = min(abs(l) + abs(l - r), abs(r) + abs(l - r))

    ans = min(ans, time)

print(ans)
import sys

input = sys.stdin.readline

INF = float("inf")





def main():

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

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

    if n == 1 and k == 1:

        print((0))

        exit()

    ans = INF

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

        l, r = X[i], X[i + k - 1]

        tmp = r - l

        if l * r < 0:

            tmp += min(abs(l), abs(r))

        else:

            tmp += min(abs(l), abs(r))

        ans = min(tmp, ans)

    print(ans)





if __name__ == '__main__':

    main()
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 10**10
for i in range(n - k + 1):
    l, r = a[i], a[i + k - 1]
    time = min(abs(l) + abs(l - r), abs(r) + abs(l - r))
    ans = min(ans, time)
print(ans)

import sys

input = sys.stdin.readline
INF = float("inf")


def main():
    n, k = list(map(int, input().split()))
    X = list(map(int, input().split()))
    if n == 1 and k == 1:
        print((0))
        exit()
    ans = INF
    for i in range(n - k + 1):
        l, r = X[i], X[i + k - 1]
        tmp = r - l
        if l * r < 0:
            tmp += min(abs(l), abs(r))
        else:
            tmp += min(abs(l), abs(r))
        ans = min(tmp, ans)
    print(ans)


if __name__ == "__main__":
    main()

-n, k = list(map(int, input().split())) -a = list(map(int, input().split())) -ans = 10**10 -for i in range(n - k + 1): -    l, r = a[i], a[i + k - 1] -    time = min(abs(l) + abs(l - r), abs(r) + abs(l - r)) -    ans = min(ans, time) -print(ans) +import sys + +input = sys.stdin.readline +INF = float("inf") + + +def main(): +    n, k = list(map(int, input().split())) +    X = list(map(int, input().split())) +    if n == 1 and k == 1: +        print((0)) +        exit() +    ans = INF +    for i in range(n - k + 1): +        l, r = X[i], X[i + k - 1] +        tmp = r - l +        if l * r < 0: +            tmp += min(abs(l), abs(r)) +        else: +            tmp += min(abs(l), abs(r)) +        ans = min(tmp, ans) +    print(ans) + + +if __name__ == "__main__": +    main()