import sys, os, bisect



f = lambda:list(map(int,input().split()))

if 'local' in os.environ :

    sys.stdin = open('./input.txt', 'r')



def solve():

    n , k = f()

    a = f()



    ans = int(1e10)

    for i in range(n):

        if i+k-1<n:

            cur_ans = 0

            if a[i]* a[i+k-1]>=0:

                cur_ans = max(abs(a[i+k-1]),abs(a[i]))

            else:

                cur_ans = min(2*abs(a[i])+abs(a[i+k-1]), abs(a[i]) + 2*abs(a[i+k-1]))

            ans = min(ans, cur_ans)

    

    print(ans)



solve()

import sys, os, bisect



f = lambda:list(map(int,input().split()))

if 'local' in os.environ :

    sys.stdin = open('./input.txt', 'r')



def solve():

    n , k = f()

    a = f()



    ans = int(1e10)

    for i in range(n):

        if i+k-1<n:

            ans = min(ans,  abs(a[i]) + abs(a[i] - a[i+k-1]), abs(a[i+k-1]) + abs(a[i] - a[i+k-1]))



    print(ans)



solve()

import sys, os, bisect

f = lambda: list(map(int, input().split()))
if "local" in os.environ:
    sys.stdin = open("./input.txt", "r")


def solve():
    n, k = f()
    a = f()
    ans = int(1e10)
    for i in range(n):
        if i + k - 1 < n:
            cur_ans = 0
            if a[i] * a[i + k - 1] >= 0:
                cur_ans = max(abs(a[i + k - 1]), abs(a[i]))
            else:
                cur_ans = min(
                    2 * abs(a[i]) + abs(a[i + k - 1]), abs(a[i]) + 2 * abs(a[i + k - 1])
                )
            ans = min(ans, cur_ans)
    print(ans)


solve()

import sys, os, bisect

f = lambda: list(map(int, input().split()))
if "local" in os.environ:
    sys.stdin = open("./input.txt", "r")


def solve():
    n, k = f()
    a = f()
    ans = int(1e10)
    for i in range(n):
        if i + k - 1 < n:
            ans = min(
                ans,
                abs(a[i]) + abs(a[i] - a[i + k - 1]),
                abs(a[i + k - 1]) + abs(a[i] - a[i + k - 1]),
            )
    print(ans)


solve()

-            cur_ans = 0 -            if a[i] * a[i + k - 1] >= 0: -                cur_ans = max(abs(a[i + k - 1]), abs(a[i])) -            else: -                cur_ans = min( -                    2 * abs(a[i]) + abs(a[i + k - 1]), abs(a[i]) + 2 * abs(a[i + k - 1]) -                ) -            ans = min(ans, cur_ans) +            ans = min( +                ans, +                abs(a[i]) + abs(a[i] - a[i + k - 1]), +                abs(a[i + k - 1]) + abs(a[i] - a[i + k - 1]), +            )