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



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:

    idx = max(z - k + 1, 0)

    print((min(min(abs(i), j) + j - i for i, j in zip(lst[idx:], lst[idx + k - 1:]))))



if __name__ == '__main__':

  main()
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


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:
        idx = max(z - k + 1, 0)
        print(
            (min(min(abs(i), j) + j - i for i, j in zip(lst[idx:], lst[idx + k - 1 :])))
        )


if __name__ == "__main__":
    main()

-        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) +        idx = max(z - k + 1, 0) +        print( +            (min(min(abs(i), j) + j - i for i, j in zip(lst[idx:], lst[idx + k - 1 :]))) +        )