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

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



import bisect



zero_index = bisect.bisect_left(x,0)

start_index = max(0,zero_index-k)

x = x[start_index:zero_index+k]



answer = (x[-1]-x[0])*k

for i in range(len(x)-k+1):

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

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

  else:

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



print(answer)
#!/usr/bin/env python3

import sys

from itertools import accumulate



def solve(N: int, K: int, x: "List[int]"):

    minus = []

    plus = []

    answer = 10**9

    for i in range(N):

        if x[i] >= 0:

            plus.append(x[i])

        else:

            minus.append(abs(x[i]))

    minus = minus[::-1]



    for plus_count in range(0,K+1):

        minus_count = K- plus_count



    

        if 0 <= plus_count <= len(plus) and 0 <= minus_count <= len(minus):

            if plus_count == 0:

                answer = min(answer,minus[minus_count-1])

            elif minus_count ==0:

                answer = min(answer,plus[plus_count-1])

            else:

                answer = min(answer,plus[plus_count-1]+minus[minus_count-1]*2,plus[plus_count-1]*2+minus[minus_count-1])   



    print(answer)    

    return





def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    K = int(next(tokens))  # type: int

    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, K, x)



if __name__ == '__main__':

    main()

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

zero_index = bisect.bisect_left(x, 0)
start_index = max(0, zero_index - k)
x = x[start_index : zero_index + k]
answer = (x[-1] - x[0]) * k
for i in range(len(x) - k + 1):
    if x[i + k - 1] * x[i] > 0:
        answer = min(answer, max(abs(x[i + k - 1]), abs(x[i])))
    else:
        answer = min(
            answer,
            min(abs(x[i + k - 1]), abs(x[i])) * 2 + max(abs(x[i + k - 1]), abs(x[i])),
        )
print(answer)

#!/usr/bin/env python3
import sys
from itertools import accumulate


def solve(N: int, K: int, x: "List[int]"):
    minus = []
    plus = []
    answer = 10**9
    for i in range(N):
        if x[i] >= 0:
            plus.append(x[i])
        else:
            minus.append(abs(x[i]))
    minus = minus[::-1]
    for plus_count in range(0, K + 1):
        minus_count = K - plus_count
        if 0 <= plus_count <= len(plus) and 0 <= minus_count <= len(minus):
            if plus_count == 0:
                answer = min(answer, minus[minus_count - 1])
            elif minus_count == 0:
                answer = min(answer, plus[plus_count - 1])
            else:
                answer = min(
                    answer,
                    plus[plus_count - 1] + minus[minus_count - 1] * 2,
                    plus[plus_count - 1] * 2 + minus[minus_count - 1],
                )
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)


if __name__ == "__main__":
    main()

-n, k = list(map(int, input().split())) -x = list(map(int, input().split())) -import bisect +#!/usr/bin/env python3 +import sys +from itertools import accumulate -zero_index = bisect.bisect_left(x, 0) -start_index = max(0, zero_index - k) -x = x[start_index : zero_index + k] -answer = (x[-1] - x[0]) * k -for i in range(len(x) - k + 1): -    if x[i + k - 1] * x[i] > 0: -        answer = min(answer, max(abs(x[i + k - 1]), abs(x[i]))) -    else: -        answer = min( -            answer, -            min(abs(x[i + k - 1]), abs(x[i])) * 2 + max(abs(x[i + k - 1]), abs(x[i])), -        ) -print(answer) + +def solve(N: int, K: int, x: "List[int]"): +    minus = [] +    plus = [] +    answer = 10**9 +    for i in range(N): +        if x[i] >= 0: +            plus.append(x[i]) +        else: +            minus.append(abs(x[i])) +    minus = minus[::-1] +    for plus_count in range(0, K + 1): +        minus_count = K - plus_count +        if 0 <= plus_count <= len(plus) and 0 <= minus_count <= len(minus): +            if plus_count == 0: +                answer = min(answer, minus[minus_count - 1]) +            elif minus_count == 0: +                answer = min(answer, plus[plus_count - 1]) +            else: +                answer = min( +                    answer, +                    plus[plus_count - 1] + minus[minus_count - 1] * 2, +                    plus[plus_count - 1] * 2 + minus[minus_count - 1], +                ) +    print(answer) +    return + + +def main(): +    def iterate_tokens(): +        for line in sys.stdin: +            for word in line.split(): +                yield word + +    tokens = iterate_tokens() +    N = int(next(tokens))  # type: int +    K = int(next(tokens))  # type: int +    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]" +    solve(N, K, x) + + +if __name__ == "__main__": +    main()