def main():

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

    f = lambda i: x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))

    l = f(0)



    for i in range(n - k + 1):

        y = f(i)

        if y < l:

            l = y



    print(l)





if __name__ == '__main__':

    main()

def main():

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

    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))



    for i in range(n - k + 1):

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

        if y < l:

            l = y



    print(l)





if __name__ == '__main__':

    main()

def main():
    n, k, *x = list(map(int, open(0).read().split()))
    f = lambda i: x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
    l = f(0)
    for i in range(n - k + 1):
        y = f(i)
        if y < l:
            l = y
    print(l)


if __name__ == "__main__":
    main()

def main():
    n, k, *x = list(map(int, open(0).read().split()))
    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
    for i in range(n - k + 1):
        y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
        if y < l:
            l = y
    print(l)


if __name__ == "__main__":
    main()

-    f = lambda i: x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i])) -    l = f(0) +    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0])) -        y = f(i) +        y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))