#!/usr/bin/env python3

import sys, math, itertools, heapq, collections, bisect, string, copy

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

sys.setrecursionlimit(10**8)

inf = float('inf')

mod = 10**9+7

ans = inf 

count = 0; pro = 1



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

A=[]; B=[]

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

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

    candi = max(abs(x[i+k-1]),abs(x[i]))

    if x[i+k-1]*x[i]<0:

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



    ans = min(ans, candi)

print(ans)

#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf') ;mod = 10**9+7

mans = inf ;ans = 0 ;count = 0 ;pro = 1



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

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

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

  fi = X[i]

  en = X[i+k-1]

  if fi <= 0 and en >= 0:

    mans = min(mans,min(-fi,en)-fi+en)

  else:

    mans=min(mans,max(abs(fi),abs(en)))

print(mans)
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
sys.setrecursionlimit(10**8)
inf = float("inf")
mod = 10**9 + 7
ans = inf
count = 0
pro = 1
n, k = list(map(int, input().split()))
A = []
B = []
x = list(map(int, input().split()))
for i in range(n - (k - 1)):
    candi = max(abs(x[i + k - 1]), abs(x[i]))
    if x[i + k - 1] * x[i] < 0:
        candi += 2 * min(abs(x[i + k - 1]), abs(x[i]))
    ans = min(ans, candi)
print(ans)

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n, k = list(map(int, input().split()))
X = list(map(int, input().split()))
for i in range(n - k + 1):
    fi = X[i]
    en = X[i + k - 1]
    if fi <= 0 and en >= 0:
        mans = min(mans, min(-fi, en) - fi + en)
    else:
        mans = min(mans, max(abs(fi), abs(en)))
print(mans)

-import sys, math, itertools, heapq, collections, bisect, string, copy +import sys, math, itertools, collections, bisect -sys.setrecursionlimit(10**8) -ans = inf +mans = inf +ans = 0 -A = [] -B = [] -x = list(map(int, input().split())) -for i in range(n - (k - 1)): -    candi = max(abs(x[i + k - 1]), abs(x[i])) -    if x[i + k - 1] * x[i] < 0: -        candi += 2 * min(abs(x[i + k - 1]), abs(x[i])) -    ans = min(ans, candi) -print(ans) +X = list(map(int, input().split())) +for i in range(n - k + 1): +    fi = X[i] +    en = X[i + k - 1] +    if fi <= 0 and en >= 0: +        mans = min(mans, min(-fi, en) - fi + en) +    else: +        mans = min(mans, max(abs(fi), abs(en))) +print(mans)