import sys

 

stdin = sys.stdin



mod = 1000000007

inf = 1 << 60

 

ni = lambda: int(ns())

na = lambda: list(map(int, stdin.readline().split()))

ns = lambda: stdin.readline().rstrip()

nas = lambda: stdin.readline().split()



n, k = na()

x = na()



ans = inf

for i in range(n):

    if i + k - 1 < n:

        l, r = x[i], x[i + k - 1]

        ans = min(ans, min(abs(l) + abs(r - l), abs(r) + abs(r - l)))



print(ans)
import sys



stdin = sys.stdin

inf = 1 << 60

mod = 1000000007



ni      = lambda: int(ns())

nin     = lambda y: [ni() for _ in range(y)]

na      = lambda: list(map(int, stdin.readline().split()))

nan     = lambda y: [na() for _ in range(y)]

nf      = lambda: float(ns())

nfn     = lambda y: [nf() for _ in range(y)]

nfa     = lambda: list(map(float, stdin.readline().split()))

nfan    = lambda y: [nfa() for _ in range(y)]

ns      = lambda: stdin.readline().rstrip()

nsn     = lambda y: [ns() for _ in range(y)]

ncl     = lambda y: [list(ns()) for _ in range(y)]

nas     = lambda: stdin.readline().split()



n, k = na()

x = na()



def dist(l, r):

    mn = min(abs(l), abs(r))

    mx = max(abs(l), abs(r))

    if l < 0 and r < 0:

        return mx

    elif l >= 0 and r >= 0:

        return mx

    else:

        return mn * 2 + mx



ans = inf

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

    ans = min(ans, dist(x[i], x[i + k - 1]))



print(ans)
import sys

stdin = sys.stdin
mod = 1000000007
inf = 1 << 60
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
n, k = na()
x = na()
ans = inf
for i in range(n):
    if i + k - 1 < n:
        l, r = x[i], x[i + k - 1]
        ans = min(ans, min(abs(l) + abs(r - l), abs(r) + abs(r - l)))
print(ans)

import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
n, k = na()
x = na()


def dist(l, r):
    mn = min(abs(l), abs(r))
    mx = max(abs(l), abs(r))
    if l < 0 and r < 0:
        return mx
    elif l >= 0 and r >= 0:
        return mx
    else:
        return mn * 2 + mx


ans = inf
for i in range(n - k + 1):
    ans = min(ans, dist(x[i], x[i + k - 1]))
print(ans)

+inf = 1 << 60 -inf = 1 << 60 +nin = lambda y: [ni() for _ in range(y)] +nan = lambda y: [na() for _ in range(y)] +nf = lambda: float(ns()) +nfn = lambda y: [nf() for _ in range(y)] +nfa = lambda: list(map(float, stdin.readline().split())) +nfan = lambda y: [nfa() for _ in range(y)] +nsn = lambda y: [ns() for _ in range(y)] +ncl = lambda y: [list(ns()) for _ in range(y)] + + +def dist(l, r): +    mn = min(abs(l), abs(r)) +    mx = max(abs(l), abs(r)) +    if l < 0 and r < 0: +        return mx +    elif l >= 0 and r >= 0: +        return mx +    else: +        return mn * 2 + mx + + -for i in range(n): -    if i + k - 1 < n: -        l, r = x[i], x[i + k - 1] -        ans = min(ans, min(abs(l) + abs(r - l), abs(r) + abs(r - l))) +for i in range(n - k + 1): +    ans = min(ans, dist(x[i], x[i + k - 1]))