import sys

input = sys.stdin.readline





def main():

    N, K = list(map(int, input().split()))

    X = [int(c) for c in input().split()]



    def fullsearch():

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

            l = X[i]

            r = X[i+K-1]

            distance = abs(r - l)

            yield min(distance + abs(r), distance + abs(l))



    print((min(fullsearch())))



main()
import sys

input = sys.stdin.readline





def main():

    _, K = list(map(int, input().split()))

    X = [int(c) for c in input().split()]



    def fullsearch():

        for l, r in zip(X, X[K-1:]):

            distance = abs(r - l)

            yield distance + abs(r)

            yield distance + abs(l)



    print((min(fullsearch())))



main()
import sys

input = sys.stdin.readline


def main():
    N, K = list(map(int, input().split()))
    X = [int(c) for c in input().split()]

    def fullsearch():
        for i in range(N - K + 1):
            l = X[i]
            r = X[i + K - 1]
            distance = abs(r - l)
            yield min(distance + abs(r), distance + abs(l))

    print((min(fullsearch())))


main()

import sys

input = sys.stdin.readline


def main():
    _, K = list(map(int, input().split()))
    X = [int(c) for c in input().split()]

    def fullsearch():
        for l, r in zip(X, X[K - 1 :]):
            distance = abs(r - l)
            yield distance + abs(r)
            yield distance + abs(l)

    print((min(fullsearch())))


main()

-    N, K = list(map(int, input().split())) +    _, K = list(map(int, input().split())) -        for i in range(N - K + 1): -            l = X[i] -            r = X[i + K - 1] +        for l, r in zip(X, X[K - 1 :]): -            yield min(distance + abs(r), distance + abs(l)) +            yield distance + abs(r) +            yield distance + abs(l)