inf = float('inf')



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

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



m, p = [], []

for xx in x:

    if xx > 0:

        p.append(xx)

    elif xx < 0:

        m.append(-xx)

    else:

        K -= 1

        if K == 0:

            print((0))

            exit()

m.sort()

lp = len(p)

lm = len(m)



ans = inf

for from_minus in range(min(lm, K) + 1):

    from_plus = K - from_minus

    if from_plus > lp:

        continue

    if from_minus == 0:

        ans = min(ans, p[K - 1])

    elif from_minus == K:

        ans = min(ans, m[K - 1])

    else:

        ans = min(ans, p[from_plus - 1] * 2 + m[from_minus - 1])

        ans = min(ans, m[from_minus - 1] * 2 + p[from_plus - 1])

print(ans)

def main():

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

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



    ans = 3 * 10 ** 8

    for left, right in zip(x, x[K - 1:]):

        if left * right < 0:

            ans = min(ans, right - left + min(-left, right))

        else:

            ans = min(ans, -left if left < 0 else right)

    print(ans)





if __name__ == '__main__':

    main()



# import sys

# input = sys.stdin.readline

# 

# sys.setrecursionlimit(10 ** 7)

# 

# (int(x)-1 for x in input().split())

# rstrip()

#

# def binary_search(*, ok, ng, func):

#     while abs(ok - ng) > 1:

#         mid = (ok + ng) // 2

#         if func(mid):

#             ok = mid

#         else:

#             ng = mid

#     return ok

inf = float("inf")
N, K = list(map(int, input().split()))
x = tuple(map(int, input().split()))
m, p = [], []
for xx in x:
    if xx > 0:
        p.append(xx)
    elif xx < 0:
        m.append(-xx)
    else:
        K -= 1
        if K == 0:
            print((0))
            exit()
m.sort()
lp = len(p)
lm = len(m)
ans = inf
for from_minus in range(min(lm, K) + 1):
    from_plus = K - from_minus
    if from_plus > lp:
        continue
    if from_minus == 0:
        ans = min(ans, p[K - 1])
    elif from_minus == K:
        ans = min(ans, m[K - 1])
    else:
        ans = min(ans, p[from_plus - 1] * 2 + m[from_minus - 1])
        ans = min(ans, m[from_minus - 1] * 2 + p[from_plus - 1])
print(ans)

def main():
    N, K = list(map(int, input().split()))
    (*x,) = list(map(int, input().split()))
    ans = 3 * 10**8
    for left, right in zip(x, x[K - 1 :]):
        if left * right < 0:
            ans = min(ans, right - left + min(-left, right))
        else:
            ans = min(ans, -left if left < 0 else right)
    print(ans)


if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

-inf = float("inf") -N, K = list(map(int, input().split())) -x = tuple(map(int, input().split())) -m, p = [], [] -for xx in x: -    if xx > 0: -        p.append(xx) -    elif xx < 0: -        m.append(-xx) -    else: -        K -= 1 -        if K == 0: -            print((0)) -            exit() -m.sort() -lp = len(p) -lm = len(m) -ans = inf -for from_minus in range(min(lm, K) + 1): -    from_plus = K - from_minus -    if from_plus > lp: -        continue -    if from_minus == 0: -        ans = min(ans, p[K - 1]) -    elif from_minus == K: -        ans = min(ans, m[K - 1]) -    else: -        ans = min(ans, p[from_plus - 1] * 2 + m[from_minus - 1]) -        ans = min(ans, m[from_minus - 1] * 2 + p[from_plus - 1]) -print(ans) +def main(): +    N, K = list(map(int, input().split())) +    (*x,) = list(map(int, input().split())) +    ans = 3 * 10**8 +    for left, right in zip(x, x[K - 1 :]): +        if left * right < 0: +            ans = min(ans, right - left + min(-left, right)) +        else: +            ans = min(ans, -left if left < 0 else right) +    print(ans) + + +if __name__ == "__main__": +    main() +# import sys +# input = sys.stdin.readline +# +# sys.setrecursionlimit(10 ** 7) +# +# (int(x)-1 for x in input().split()) +# rstrip() +# +# def binary_search(*, ok, ng, func): +#     while abs(ok - ng) > 1: +#         mid = (ok + ng) // 2 +#         if func(mid): +#             ok = mid +#         else: +#             ng = mid +#     return ok