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

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



ans=10**9



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

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

    ans=min(ans,-x[i])

  elif x[i]>0:

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

  else:

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



print(ans)
import sys

input = sys.stdin.buffer.readline

input = sys.stdin.readline





# mod=10**9+7

# rstrip().decode('utf-8')

# map(int,input().split())

#import numpy as np



def main():

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

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



	ans=10**18



	for i in range(n):

		try:

			l=x[i]

			r=x[i+k-1]

			if r<0:

				ans=min(ans,-l)

			elif l>0:

				ans=min(ans,r)

			else:

				ans=min(ans,r-l+min(-l,r))

		except:

			pass

	print(ans)







if __name__ == "__main__":

	main()

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10**9
for i in range(n - k + 1):
    if x[i + k - 1] < 0:
        ans = min(ans, -x[i])
    elif x[i] > 0:
        ans = min(ans, x[i + k - 1])
    else:
        ans = min(ans, 2 * x[i + k - 1] - x[i], 2 * (-x[i]) + x[i + k - 1])
print(ans)

import sys

input = sys.stdin.buffer.readline
input = sys.stdin.readline
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
def main():
    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = 10**18
    for i in range(n):
        try:
            l = x[i]
            r = x[i + k - 1]
            if r < 0:
                ans = min(ans, -l)
            elif l > 0:
                ans = min(ans, r)
            else:
                ans = min(ans, r - l + min(-l, r))
        except:
            pass
    print(ans)


if __name__ == "__main__":
    main()

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -ans = 10**9 -for i in range(n - k + 1): -    if x[i + k - 1] < 0: -        ans = min(ans, -x[i]) -    elif x[i] > 0: -        ans = min(ans, x[i + k - 1]) -    else: -        ans = min(ans, 2 * x[i + k - 1] - x[i], 2 * (-x[i]) + x[i + k - 1]) -print(ans) +import sys + +input = sys.stdin.buffer.readline +input = sys.stdin.readline +# mod=10**9+7 +# rstrip().decode('utf-8') +# map(int,input().split()) +# import numpy as np +def main(): +    n, k = list(map(int, input().split())) +    x = list(map(int, input().split())) +    ans = 10**18 +    for i in range(n): +        try: +            l = x[i] +            r = x[i + k - 1] +            if r < 0: +                ans = min(ans, -l) +            elif l > 0: +                ans = min(ans, r) +            else: +                ans = min(ans, r - l + min(-l, r)) +        except: +            pass +    print(ans) + + +if __name__ == "__main__": +    main()