a = [list(map(int, input().split())) for i in range(2)]

k = a[0][1]



num_list = a[1]



positive_list = []

negative_list = []



ans_positive = []

ans_negative = []



ans_list = []



for _ in num_list:

    if _ > 0:

        positive_list.append(_)

    elif _ < 0:

        negative_list.insert(0, _)

    else:

        if num_list != [0]:

            k -= 1



for _ in list(range(len(positive_list))):

    if not 0 <= k - _ - 2 < len(negative_list):

        continue

    ans_positive.append(2 * positive_list[_] - negative_list[k - _ - 2])



for _ in list(range(len(negative_list))):

    if not 0 <= k - _ - 2 < len(positive_list):

        continue

    ans_negative.append(-2 * negative_list[_] + positive_list[k - _ - 2])



if ans_positive:

    ans_list.append(min(ans_positive))



if ans_negative:

    ans_list.append(min(ans_negative))



if k <= len(positive_list):

    ans_list.append(positive_list[k - 1])



if k <= len(negative_list):

    ans_list.append(-1 * negative_list[k - 1])



if ans_list == []:

    print((0))



else:

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

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

 

ans = []

 

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

    ans.append(abs(x[k + _ - 1]) + abs(x[k + _ - 1] - x[_]))

    ans.append(abs(x[_]) + abs(x[_] - x[k + _ - 1]))

    

 

print((min(ans)))
a = [list(map(int, input().split())) for i in range(2)]
k = a[0][1]
num_list = a[1]
positive_list = []
negative_list = []
ans_positive = []
ans_negative = []
ans_list = []
for _ in num_list:
    if _ > 0:
        positive_list.append(_)
    elif _ < 0:
        negative_list.insert(0, _)
    else:
        if num_list != [0]:
            k -= 1
for _ in list(range(len(positive_list))):
    if not 0 <= k - _ - 2 < len(negative_list):
        continue
    ans_positive.append(2 * positive_list[_] - negative_list[k - _ - 2])
for _ in list(range(len(negative_list))):
    if not 0 <= k - _ - 2 < len(positive_list):
        continue
    ans_negative.append(-2 * negative_list[_] + positive_list[k - _ - 2])
if ans_positive:
    ans_list.append(min(ans_positive))
if ans_negative:
    ans_list.append(min(ans_negative))
if k <= len(positive_list):
    ans_list.append(positive_list[k - 1])
if k <= len(negative_list):
    ans_list.append(-1 * negative_list[k - 1])
if ans_list == []:
    print((0))
else:
    print((min(ans_list)))

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = []
for _ in range(n - k + 1):
    ans.append(abs(x[k + _ - 1]) + abs(x[k + _ - 1] - x[_]))
    ans.append(abs(x[_]) + abs(x[_] - x[k + _ - 1]))
print((min(ans)))

-a = [list(map(int, input().split())) for i in range(2)] -k = a[0][1] -num_list = a[1] -positive_list = [] -negative_list = [] -ans_positive = [] -ans_negative = [] -ans_list = [] -for _ in num_list: -    if _ > 0: -        positive_list.append(_) -    elif _ < 0: -        negative_list.insert(0, _) -    else: -        if num_list != [0]: -            k -= 1 -for _ in list(range(len(positive_list))): -    if not 0 <= k - _ - 2 < len(negative_list): -        continue -    ans_positive.append(2 * positive_list[_] - negative_list[k - _ - 2]) -for _ in list(range(len(negative_list))): -    if not 0 <= k - _ - 2 < len(positive_list): -        continue -    ans_negative.append(-2 * negative_list[_] + positive_list[k - _ - 2]) -if ans_positive: -    ans_list.append(min(ans_positive)) -if ans_negative: -    ans_list.append(min(ans_negative)) -if k <= len(positive_list): -    ans_list.append(positive_list[k - 1]) -if k <= len(negative_list): -    ans_list.append(-1 * negative_list[k - 1]) -if ans_list == []: -    print((0)) -else: -    print((min(ans_list))) +n, k = list(map(int, input().split())) +x = list(map(int, input().split())) +ans = [] +for _ in range(n - k + 1): +    ans.append(abs(x[k + _ - 1]) + abs(x[k + _ - 1] - x[_])) +    ans.append(abs(x[_]) + abs(x[_] - x[k + _ - 1])) +print((min(ans)))