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

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

xp=[xi for xi in x if xi>=0]

xm=[xi for xi in x if xi<0]

xm.sort(reverse=True)

ans=3*10**8

for i in range(k+1):

    # xpからi個のろうそくをつける。xmからはk-i個火をつける

    if i>len(xp) or k-i>len(xm):

        continue

    a=xp[i-1] if len(xp)>0 and i>0 else 0

    b=xm[k-i-1] if len(xm)>0 and k-i>0 else 0

    ans=min(ans,2*a-b,a-2*b)

print(ans)



def main():

  import bisect

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

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

  ans=abs(x[0])*2+abs(x[-1])*2

  if 0 in x:

    r=x.index(0)

    l=max(0,r-(k-1))

  else:

    r=bisect.bisect_right(x,0)

    l=max(0,r-k)

  ans=2*abs(x[0])+2*abs(x[-1])

  for i in range(l,min(n-k+1,r+1)):

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

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

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

      ans=min(ans,2*a+b)

    else:

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

      ans=min(ans,b)

  print(ans)

if __name__=='__main__':

  main()

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))
xp = [xi for xi in x if xi >= 0]
xm = [xi for xi in x if xi < 0]
xm.sort(reverse=True)
ans = 3 * 10**8
for i in range(k + 1):
    # xpからi個のろうそくをつける。xmからはk-i個火をつける
    if i > len(xp) or k - i > len(xm):
        continue
    a = xp[i - 1] if len(xp) > 0 and i > 0 else 0
    b = xm[k - i - 1] if len(xm) > 0 and k - i > 0 else 0
    ans = min(ans, 2 * a - b, a - 2 * b)
print(ans)

def main():
    import bisect

    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = abs(x[0]) * 2 + abs(x[-1]) * 2
    if 0 in x:
        r = x.index(0)
        l = max(0, r - (k - 1))
    else:
        r = bisect.bisect_right(x, 0)
        l = max(0, r - k)
    ans = 2 * abs(x[0]) + 2 * abs(x[-1])
    for i in range(l, min(n - k + 1, r + 1)):
        if x[i] * x[i + k - 1] <= 0:
            a = min(abs(x[i]), abs(x[i + k - 1]))
            b = max(abs(x[i]), abs(x[i + k - 1]))
            ans = min(ans, 2 * a + b)
        else:
            b = max(abs(x[i]), abs(x[i + k - 1]))
            ans = min(ans, b)
    print(ans)


if __name__ == "__main__":
    main()

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -xp = [xi for xi in x if xi >= 0] -xm = [xi for xi in x if xi < 0] -xm.sort(reverse=True) -ans = 3 * 10**8 -for i in range(k + 1): -    # xpからi個のろうそくをつける。xmからはk-i個火をつける -    if i > len(xp) or k - i > len(xm): -        continue -    a = xp[i - 1] if len(xp) > 0 and i > 0 else 0 -    b = xm[k - i - 1] if len(xm) > 0 and k - i > 0 else 0 -    ans = min(ans, 2 * a - b, a - 2 * b) -print(ans) +def main(): +    import bisect + +    n, k = list(map(int, input().split())) +    x = list(map(int, input().split())) +    ans = abs(x[0]) * 2 + abs(x[-1]) * 2 +    if 0 in x: +        r = x.index(0) +        l = max(0, r - (k - 1)) +    else: +        r = bisect.bisect_right(x, 0) +        l = max(0, r - k) +    ans = 2 * abs(x[0]) + 2 * abs(x[-1]) +    for i in range(l, min(n - k + 1, r + 1)): +        if x[i] * x[i + k - 1] <= 0: +            a = min(abs(x[i]), abs(x[i + k - 1])) +            b = max(abs(x[i]), abs(x[i + k - 1])) +            ans = min(ans, 2 * a + b) +        else: +            b = max(abs(x[i]), abs(x[i + k - 1])) +            ans = min(ans, b) +    print(ans) + + +if __name__ == "__main__": +    main()