import numpy as np



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

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

min_t = None

for i in range(N-K+1):

  t = min(abs(x[i])+abs(x[i]-x[i+K-1]), abs(x[i+K-1])+abs(x[i]-x[i+K-1]))

  if min_t == None:

    min_t = t

  if min_t > t:

    min_t = t

print(min_t)

  



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

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

INF = float("inf")

cost = INF

for i in range(len(x)-k+1):

  l = x[i]

  r = x[i+k-1]

  tmp = min(abs(l)+abs(l-r),abs(r)+abs(r-l))

  cost = min(cost,tmp)

print(cost)

import numpy as np

N, K = list(map(int, input().split()))
x = list(map(int, input().split()))
min_t = None
for i in range(N - K + 1):
    t = min(
        abs(x[i]) + abs(x[i] - x[i + K - 1]),
        abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]),
    )
    if min_t == None:
        min_t = t
    if min_t > t:
        min_t = t
print(min_t)

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
INF = float("inf")
cost = INF
for i in range(len(x) - k + 1):
    l = x[i]
    r = x[i + k - 1]
    tmp = min(abs(l) + abs(l - r), abs(r) + abs(r - l))
    cost = min(cost, tmp)
print(cost)

-import numpy as np - -N, K = list(map(int, input().split())) +n, k = list(map(int, input().split())) -min_t = None -for i in range(N - K + 1): -    t = min( -        abs(x[i]) + abs(x[i] - x[i + K - 1]), -        abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]), -    ) -    if min_t == None: -        min_t = t -    if min_t > t: -        min_t = t -print(min_t) +INF = float("inf") +cost = INF +for i in range(len(x) - k + 1): +    l = x[i] +    r = x[i + k - 1] +    tmp = min(abs(l) + abs(l - r), abs(r) + abs(r - l)) +    cost = min(cost, tmp) +print(cost)