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

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



ans = 10**9

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

  xs = abs(x[i+k-1]-x[i])

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

  

print(ans)
import bisect

import sys



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

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



index = bisect.bisect_left(x,0)



if x[0] >= 0 :

  print((x[k-1]))

  sys.exit()

  

if x[-1] <= 0 :

  print((x[n-k]*(-1)))

  sys.exit()



ans = 10**9

if min(index+k,n) == index+k :

  ans = x[index+k-1]



if max(0,index-k) == index - k :

  ans = min(ans,x[index-k]*(-1))

  

c = 0

for i in range(index,min(index+k,n)) :

  c += 1

  if i <= n-1 and i-(k-1) <= n-1 and i-(k-1) >= 0 :

    ans = min(ans,x[i]*2+x[i-(k-1)]*(-1))



c = 0

for i in range(max(0,index-k),index) :

  c += 1

  if i <= n-1 and i+(k-1) <= n-1 :

    ans = min(ans,x[i]*(-1)*2+x[i+(k-1)])

  

print(ans)
n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**9
for i in range(n - k + 1):
    xs = abs(x[i + k - 1] - x[i])
    ans = min(ans, xs + abs(x[i]), xs + abs(x[i + k - 1]))
print(ans)

import bisect
import sys

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
index = bisect.bisect_left(x, 0)
if x[0] >= 0:
    print((x[k - 1]))
    sys.exit()
if x[-1] <= 0:
    print((x[n - k] * (-1)))
    sys.exit()
ans = 10**9
if min(index + k, n) == index + k:
    ans = x[index + k - 1]
if max(0, index - k) == index - k:
    ans = min(ans, x[index - k] * (-1))
c = 0
for i in range(index, min(index + k, n)):
    c += 1
    if i <= n - 1 and i - (k - 1) <= n - 1 and i - (k - 1) >= 0:
        ans = min(ans, x[i] * 2 + x[i - (k - 1)] * (-1))
c = 0
for i in range(max(0, index - k), index):
    c += 1
    if i <= n - 1 and i + (k - 1) <= n - 1:
        ans = min(ans, x[i] * (-1) * 2 + x[i + (k - 1)])
print(ans)

+import bisect +import sys + +index = bisect.bisect_left(x, 0) +if x[0] >= 0: +    print((x[k - 1])) +    sys.exit() +if x[-1] <= 0: +    print((x[n - k] * (-1))) +    sys.exit() -for i in range(n - k + 1): -    xs = abs(x[i + k - 1] - x[i]) -    ans = min(ans, xs + abs(x[i]), xs + abs(x[i + k - 1])) +if min(index + k, n) == index + k: +    ans = x[index + k - 1] +if max(0, index - k) == index - k: +    ans = min(ans, x[index - k] * (-1)) +c = 0 +for i in range(index, min(index + k, n)): +    c += 1 +    if i <= n - 1 and i - (k - 1) <= n - 1 and i - (k - 1) >= 0: +        ans = min(ans, x[i] * 2 + x[i - (k - 1)] * (-1)) +c = 0 +for i in range(max(0, index - k), index): +    c += 1 +    if i <= n - 1 and i + (k - 1) <= n - 1: +        ans = min(ans, x[i] * (-1) * 2 + x[i + (k - 1)])