import sys

input = sys.stdin.readline





def main():

    N, K = [int(x) for x in input().split()]

    x = [int(x) for x in input().split()]



    plus = [0]

    j = 0

    for i in range(N):

        if x[i] >= 0:

            plus.append(x[i])

            j += 1



    j = 0

    minus = [0]

    for i in range(N - 1, -1, -1):

        if x[i] < 0:

            minus.append(x[i])

            j += 1



    ans = float("inf")

    for i in range(0, K + 1):

        if len(plus) - 1 < i:

            continue



        if len(minus) - 1 < K - i:

            continue





        rsum = plus[i]

        lsum = abs(minus[K - i])



        if rsum >= lsum:

            ans = min(ans, rsum + lsum * 2)

        else:

            ans = min(ans, rsum * 2 + lsum)



    print(ans)



    





if __name__ == '__main__':

    main()



import sys

input = sys.stdin.readline





def main():

    N, K = [int(x) for x in input().split()]

    x = [int(x) for x in input().split()]



    ans = float("inf")

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

        l = x[i]

        r = x[i + K - 1]

        if l < 0 < r:

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

        else:

            ans = min(ans, max(abs(l), abs(r)))



    print(ans)



    





if __name__ == '__main__':

    main()



import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    x = [int(x) for x in input().split()]
    plus = [0]
    j = 0
    for i in range(N):
        if x[i] >= 0:
            plus.append(x[i])
            j += 1
    j = 0
    minus = [0]
    for i in range(N - 1, -1, -1):
        if x[i] < 0:
            minus.append(x[i])
            j += 1
    ans = float("inf")
    for i in range(0, K + 1):
        if len(plus) - 1 < i:
            continue
        if len(minus) - 1 < K - i:
            continue
        rsum = plus[i]
        lsum = abs(minus[K - i])
        if rsum >= lsum:
            ans = min(ans, rsum + lsum * 2)
        else:
            ans = min(ans, rsum * 2 + lsum)
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    x = [int(x) for x in input().split()]
    ans = float("inf")
    for i in range(N + 1 - K):
        l = x[i]
        r = x[i + K - 1]
        if l < 0 < r:
            ans = min(ans, abs(l) + abs(r) + min(abs(l), abs(r)))
        else:
            ans = min(ans, max(abs(l), abs(r)))
    print(ans)


if __name__ == "__main__":
    main()

-    plus = [0] -    j = 0 -    for i in range(N): -        if x[i] >= 0: -            plus.append(x[i]) -            j += 1 -    j = 0 -    minus = [0] -    for i in range(N - 1, -1, -1): -        if x[i] < 0: -            minus.append(x[i]) -            j += 1 -    for i in range(0, K + 1): -        if len(plus) - 1 < i: -            continue -        if len(minus) - 1 < K - i: -            continue -        rsum = plus[i] -        lsum = abs(minus[K - i]) -        if rsum >= lsum: -            ans = min(ans, rsum + lsum * 2) +    for i in range(N + 1 - K): +        l = x[i] +        r = x[i + K - 1] +        if l < 0 < r: +            ans = min(ans, abs(l) + abs(r) + min(abs(l), abs(r))) -            ans = min(ans, rsum * 2 + lsum) +            ans = min(ans, max(abs(l), abs(r)))