def main():

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

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

    answer = float("inf")

    if 1 < n:

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

            if x[i + k - 1] < 0:

                answer = min(answer, -x[i])

            elif 0 < x[i]:

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

            else:

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

    else:

        answer = abs(x[0])

    print(answer)





if __name__ == '__main__':

    main()



def main():

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

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

    x.sort()

    answer = float("inf")

    if n == k:

        if n == 1:

            answer = abs(x[0])

        if 0 <= x[0]:

            answer = x[-1]

        elif x[-1] <= 0:

            answer = abs(x[0])

        else:

            answer = x[-1] - x[0] + min(abs(x[-1]), abs(x[0]))

    else:

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

            left = x[i]

            right = x[i + k - 1]

            if left * right >= 0:

                answer = min(answer, max(abs(left), abs(right)))

            else:

                answer = min(answer, right - left + min(abs(left), abs(right)))

    print(answer)





if __name__ == '__main__':

    main()



def main():
    n, k = list(map(int, input().split()))
    x = [int(x) for x in input().split()]
    answer = float("inf")
    if 1 < n:
        for i in range(n - k + 1):
            if x[i + k - 1] < 0:
                answer = min(answer, -x[i])
            elif 0 < x[i]:
                answer = min(answer, x[i + k - 1])
            else:
                answer = min(
                    answer, min(abs(x[i]), abs(x[i + k - 1])) + x[i + k - 1] - x[i]
                )
    else:
        answer = abs(x[0])
    print(answer)


if __name__ == "__main__":
    main()

def main():
    n, k = list(map(int, input().split()))
    x = [int(i) for i in input().split()]
    x.sort()
    answer = float("inf")
    if n == k:
        if n == 1:
            answer = abs(x[0])
        if 0 <= x[0]:
            answer = x[-1]
        elif x[-1] <= 0:
            answer = abs(x[0])
        else:
            answer = x[-1] - x[0] + min(abs(x[-1]), abs(x[0]))
    else:
        for i in range(n - k + 1):
            left = x[i]
            right = x[i + k - 1]
            if left * right >= 0:
                answer = min(answer, max(abs(left), abs(right)))
            else:
                answer = min(answer, right - left + min(abs(left), abs(right)))
    print(answer)


if __name__ == "__main__":
    main()

-    x = [int(x) for x in input().split()] +    x = [int(i) for i in input().split()] +    x.sort() -    if 1 < n: +    if n == k: +        if n == 1: +            answer = abs(x[0]) +        if 0 <= x[0]: +            answer = x[-1] +        elif x[-1] <= 0: +            answer = abs(x[0]) +        else: +            answer = x[-1] - x[0] + min(abs(x[-1]), abs(x[0])) +    else: -            if x[i + k - 1] < 0: -                answer = min(answer, -x[i]) -            elif 0 < x[i]: -                answer = min(answer, x[i + k - 1]) +            left = x[i] +            right = x[i + k - 1] +            if left * right >= 0: +                answer = min(answer, max(abs(left), abs(right))) -                answer = min( -                    answer, min(abs(x[i]), abs(x[i + k - 1])) + x[i + k - 1] - x[i] -                ) -    else: -        answer = abs(x[0]) +                answer = min(answer, right - left + min(abs(left), abs(right)))