def main():

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

    x = tuple(x)

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

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



    for i, j in zip(x, x[k - 1:]):

        y = j - i + min(abs(i), abs(j))

        if y < l:

            l = y



    print(l)





if __name__ == '__main__':

    main()

def main():
    n, k, *x = list(map(int, open(0).read().split()))
    x = tuple(x)
    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()))
    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))
    for i, j in zip(x, x[k - 1 :]):
        y = j - i + min(abs(i), abs(j))
        if y < l:
            l = y
    print(l)


if __name__ == "__main__":
    main()

-    x = tuple(x) -    for i in range(n - k + 1): -        y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i])) +    for i, j in zip(x, x[k - 1 :]): +        y = j - i + min(abs(i), abs(j))