def main():

    import numpy as np

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

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

    X=np.array(X)

    Xp,Xz,Xm=X[X>0],X[X==0],X[X<0]

    lp,lm=len(Xp),len(Xm)



    if 0 in Xz:

        k-=1

    if k==0:

      print((0))

      exit()

      

    ans=10**9

    if k<=lp:

        ans=min(ans,Xp[k-1])

    if k<=lm:

        ans=min(ans,-Xm[-k])



    for i in range(lp):

        j=k-i-1

        if 0<j<=lm:

            ans=min(ans,Xp[i]*2-Xm[-j])

        else:

            continue

        

    for i in range(lm,0,-1):

        j=k-i-1

        if 0<=j<lp:

            ans=min(ans,Xm[-i]*(-2)+Xp[j])

        else:

            continue

    print(ans)

   

if __name__=='__main__':

    main()
import numpy as np

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

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

X=np.array(X)

m=abs(X[:n-k+1])+abs(X[:n-k+1]-X[k-1:])

p=abs(X[k-1:])+abs(X[k-1:]-X[:n-k+1])

ans=np.min(np.minimum(p,m))

print(ans)   
def main():
    import numpy as np

    n, k = list(map(int, input().split()))
    X = list(map(int, input().split()))
    X = np.array(X)
    Xp, Xz, Xm = X[X > 0], X[X == 0], X[X < 0]
    lp, lm = len(Xp), len(Xm)
    if 0 in Xz:
        k -= 1
    if k == 0:
        print((0))
        exit()
    ans = 10**9
    if k <= lp:
        ans = min(ans, Xp[k - 1])
    if k <= lm:
        ans = min(ans, -Xm[-k])
    for i in range(lp):
        j = k - i - 1
        if 0 < j <= lm:
            ans = min(ans, Xp[i] * 2 - Xm[-j])
        else:
            continue
    for i in range(lm, 0, -1):
        j = k - i - 1
        if 0 <= j < lp:
            ans = min(ans, Xm[-i] * (-2) + Xp[j])
        else:
            continue
    print(ans)


if __name__ == "__main__":
    main()

import numpy as np

n, k = list(map(int, input().split()))
X = list(map(int, input().split()))
X = np.array(X)
m = abs(X[: n - k + 1]) + abs(X[: n - k + 1] - X[k - 1 :])
p = abs(X[k - 1 :]) + abs(X[k - 1 :] - X[: n - k + 1])
ans = np.min(np.minimum(p, m))
print(ans)

-def main(): -    import numpy as np +import numpy as np -    n, k = list(map(int, input().split())) -    X = list(map(int, input().split())) -    X = np.array(X) -    Xp, Xz, Xm = X[X > 0], X[X == 0], X[X < 0] -    lp, lm = len(Xp), len(Xm) -    if 0 in Xz: -        k -= 1 -    if k == 0: -        print((0)) -        exit() -    ans = 10**9 -    if k <= lp: -        ans = min(ans, Xp[k - 1]) -    if k <= lm: -        ans = min(ans, -Xm[-k]) -    for i in range(lp): -        j = k - i - 1 -        if 0 < j <= lm: -            ans = min(ans, Xp[i] * 2 - Xm[-j]) -        else: -            continue -    for i in range(lm, 0, -1): -        j = k - i - 1 -        if 0 <= j < lp: -            ans = min(ans, Xm[-i] * (-2) + Xp[j]) -        else: -            continue -    print(ans) - - -if __name__ == "__main__": -    main() +n, k = list(map(int, input().split())) +X = list(map(int, input().split())) +X = np.array(X) +m = abs(X[: n - k + 1]) + abs(X[: n - k + 1] - X[k - 1 :]) +p = abs(X[k - 1 :]) + abs(X[k - 1 :] - X[: n - k + 1]) +ans = np.min(np.minimum(p, m)) +print(ans)