def main():

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

    d = 2 * 10 ** 9

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

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

    print(d)





if __name__ == '__main__':

    main()

def main():

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

    l = x[k - 1] - x[0] + min(abs(x[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 < 0:

            l = y



    print(l)





if __name__ == '__main__':

    main()

def main():
    n, k, *x = list(map(int, open(0).read().split()))
    d = 2 * 10**9
    for i, j in zip(x, x[k - 1 :]):
        d = min(d, j - i + min(abs(i), abs(j)))
    print(d)


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

-    d = 2 * 10**9 +    l = x[k - 1] - x[0] + min(abs(x[k - 1]), abs(x[0])) -        d = min(d, j - i + min(abs(i), abs(j))) -    print(d) +        y = j - i + min(abs(i), abs(j)) +        if y - l < 0: +            l = y +    print(l)