import numpy as np

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

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

X2 = np.zeros((N,))

X2 += X

minus = X2[X2 < 0] * (-1)

minus.sort()

plus = X2[X2 >= 0]

lenM, lenP = len(minus), len(plus)



def length(i, j):

    if i == 0:

        return plus[j-1]

    if j == 0:

        return  minus[i-1]

    else:

        LtoR = min(minus[i-1], plus[j-1])

        return plus[j-1] + minus[i-1] + LtoR



minLength = 1000000000

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

    a, b = i, K-i

    if lenM >= a and lenP >= b :

        minLength = min(minLength, length(a, b))



print((int(minLength)))
import sys



def solve():

    input = sys.stdin.readline

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

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

    left = [0]

    right = [0]

    for x in X:

        if x < 0: left.append(-x)

        else: right.append(x)

    left.sort()

    lenl = len(left)

    lenr = len(right)

    Ans = 100000000000000

    for l in range(min(lenl, K + 1)):

        r = K - l

        if r < lenr:

            Ans = min(min(left[l], right[r]) + left[l] + right[r], Ans)

    #print(left, right)

    print(Ans)



    return 0



if __name__ == "__main__":

    solve()
import numpy as np

N, K = list(map(int, input().split()))
X = [int(_) for _ in input().split()]
X2 = np.zeros((N,))
X2 += X
minus = X2[X2 < 0] * (-1)
minus.sort()
plus = X2[X2 >= 0]
lenM, lenP = len(minus), len(plus)


def length(i, j):
    if i == 0:
        return plus[j - 1]
    if j == 0:
        return minus[i - 1]
    else:
        LtoR = min(minus[i - 1], plus[j - 1])
        return plus[j - 1] + minus[i - 1] + LtoR


minLength = 1000000000
for i in range(0, K + 1):
    a, b = i, K - i
    if lenM >= a and lenP >= b:
        minLength = min(minLength, length(a, b))
print((int(minLength)))

import sys


def solve():
    input = sys.stdin.readline
    N, K = list(map(int, input().split()))
    X = [int(x) for x in input().split()]
    left = [0]
    right = [0]
    for x in X:
        if x < 0:
            left.append(-x)
        else:
            right.append(x)
    left.sort()
    lenl = len(left)
    lenr = len(right)
    Ans = 100000000000000
    for l in range(min(lenl, K + 1)):
        r = K - l
        if r < lenr:
            Ans = min(min(left[l], right[r]) + left[l] + right[r], Ans)
    # print(left, right)
    print(Ans)
    return 0


if __name__ == "__main__":
    solve()

-import numpy as np - -N, K = list(map(int, input().split())) -X = [int(_) for _ in input().split()] -X2 = np.zeros((N,)) -X2 += X -minus = X2[X2 < 0] * (-1) -minus.sort() -plus = X2[X2 >= 0] -lenM, lenP = len(minus), len(plus) +import sys -def length(i, j): -    if i == 0: -        return plus[j - 1] -    if j == 0: -        return minus[i - 1] -    else: -        LtoR = min(minus[i - 1], plus[j - 1]) -        return plus[j - 1] + minus[i - 1] + LtoR +def solve(): +    input = sys.stdin.readline +    N, K = list(map(int, input().split())) +    X = [int(x) for x in input().split()] +    left = [0] +    right = [0] +    for x in X: +        if x < 0: +            left.append(-x) +        else: +            right.append(x) +    left.sort() +    lenl = len(left) +    lenr = len(right) +    Ans = 100000000000000 +    for l in range(min(lenl, K + 1)): +        r = K - l +        if r < lenr: +            Ans = min(min(left[l], right[r]) + left[l] + right[r], Ans) +    # print(left, right) +    print(Ans) +    return 0 -minLength = 1000000000 -for i in range(0, K + 1): -    a, b = i, K - i -    if lenM >= a and lenP >= b: -        minLength = min(minLength, length(a, b)) -print((int(minLength))) +if __name__ == "__main__": +    solve()