# ABC107C - Candles (ARC101C)

def main():

    n, k = tuple(map(int, input().rstrip().split()))

    x = tuple(map(int, input().rstrip().split()))

    ans = float("inf")

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

        a, b = x[i], x[i + k - 1]

        if a < b < 0 or 0 < a < b:

            ans = min(ans, max(abs(a), abs(b)))

        else:

            ans = min(ans, max(abs(a), abs(b)) + min(abs(a), abs(b)) * 2)

    print(ans)





if __name__ == "__main__":

    main()
# ABC107C - Candles (ARC101C)

def main():

    _, k = list(map(int, input().split()))

    x = tuple(map(int, input().split()))

    print((min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :]))))





if __name__ == "__main__":

    main()
# ABC107C - Candles (ARC101C)
def main():
    n, k = tuple(map(int, input().rstrip().split()))
    x = tuple(map(int, input().rstrip().split()))
    ans = float("inf")
    for i in range(n - k + 1):
        a, b = x[i], x[i + k - 1]
        if a < b < 0 or 0 < a < b:
            ans = min(ans, max(abs(a), abs(b)))
        else:
            ans = min(ans, max(abs(a), abs(b)) + min(abs(a), abs(b)) * 2)
    print(ans)


if __name__ == "__main__":
    main()

# ABC107C - Candles (ARC101C)
def main():
    _, k = list(map(int, input().split()))
    x = tuple(map(int, input().split()))
    print((min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :]))))


if __name__ == "__main__":
    main()

-    n, k = tuple(map(int, input().rstrip().split())) -    x = tuple(map(int, input().rstrip().split())) -    ans = float("inf") -    for i in range(n - k + 1): -        a, b = x[i], x[i + k - 1] -        if a < b < 0 or 0 < a < b: -            ans = min(ans, max(abs(a), abs(b))) -        else: -            ans = min(ans, max(abs(a), abs(b)) + min(abs(a), abs(b)) * 2) -    print(ans) +    _, k = list(map(int, input().split())) +    x = tuple(map(int, input().split())) +    print((min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :]))))