import bisect



n, k, *lst = list(map(int, open(0).read().split()))

z = bisect.bisect_left(lst, 0)

if not z:

  print((lst[k - 1]))

  quit()

if z >= n - 1:

  print((-lst[-k]))

  quit()

res = float('inf')

for i in range(max(z - k + 1, 0), min(z, n - k) + 1):

  tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])

  if tmp < res:

    res = tmp

print(res)

import bisect



def main():

  n, k, *lst = list(map(int, open(0).read().split()))

  z = bisect.bisect_left(lst, 0)

  if not z:

    print((lst[k - 1]))

  elif z >= n - 1:

    print((-lst[-k]))

  else:

    res = float('inf')

    for i in range(max(z - k + 1, 0), min(z, n - k) + 1):

      tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])

      if tmp < res:

        res = tmp

    print(res)



if __name__ == '__main__':

  main()
import bisect

n, k, *lst = list(map(int, open(0).read().split()))
z = bisect.bisect_left(lst, 0)
if not z:
    print((lst[k - 1]))
    quit()
if z >= n - 1:
    print((-lst[-k]))
    quit()
res = float("inf")
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
    tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])
    if tmp < res:
        res = tmp
print(res)

import bisect


def main():
    n, k, *lst = list(map(int, open(0).read().split()))
    z = bisect.bisect_left(lst, 0)
    if not z:
        print((lst[k - 1]))
    elif z >= n - 1:
        print((-lst[-k]))
    else:
        res = float("inf")
        for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
            tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])
            if tmp < res:
                res = tmp
        print(res)


if __name__ == "__main__":
    main()

-n, k, *lst = list(map(int, open(0).read().split())) -z = bisect.bisect_left(lst, 0) -if not z: -    print((lst[k - 1])) -    quit() -if z >= n - 1: -    print((-lst[-k])) -    quit() -res = float("inf") -for i in range(max(z - k + 1, 0), min(z, n - k) + 1): -    tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1]) -    if tmp < res: -        res = tmp -print(res) + +def main(): +    n, k, *lst = list(map(int, open(0).read().split())) +    z = bisect.bisect_left(lst, 0) +    if not z: +        print((lst[k - 1])) +    elif z >= n - 1: +        print((-lst[-k])) +    else: +        res = float("inf") +        for i in range(max(z - k + 1, 0), min(z, n - k) + 1): +            tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1]) +            if tmp < res: +                res = tmp +        print(res) + + +if __name__ == "__main__": +    main()