There are N candles placed on a number line.
The i-th candle from the left is placed on coordinate x_i.
Here, x_1 < x_2 < ... < x_N holds.
Initially, no candles are burning.
Snuke decides to light K of the N candles.
Now, he is at coordinate 0.
He can move left and right along the line with speed 1.
He can also light a candle when he is at the same position as the candle, in negligible time.
Find the minimum time required to light K candles.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - 1 \leq K \leq N
 - x_i is an integer.
 - |x_i| \leq 10^8
 - x_1 < x_2 < ... < x_N

-----Input-----
Input is given from Standard Input in the following format:
N K
x_1 x_2 ... x_N

-----Output-----
Print the minimum time required to light K candles.

-----Sample Input-----
5 3
-30 -10 10 20 50

-----Sample Output-----
40

He should move and light candles as follows:
 - Move from coordinate 0 to -10.
 - Light the second candle from the left.
 - Move from coordinate -10 to 10.
 - Light the third candle from the left.
 - Move from coordinate 10 to 20.
 - Light the fourth candle from the left.

Difficulty: EASY

Solutions:
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
print(min([x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1])) for i in range(n - k + 1)]))


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = float('INF')
for i in range(N - K + 1):
	lr = abs(X[i]) + abs(X[i] - X[i + K - 1])
	rl = abs(X[i + K - 1]) + abs(X[i + K - 1] - X[i])
	ans = min(ans, min([lr, rl]))
print(ans)


(N, K) = map(int, input().split())
L = list(map(int, input().split()))
ans = 1000000010
for i in range(N - K + 1):
	ans = min(ans, min(abs(L[i]), abs(L[i + K - 1])) + L[i + K - 1] - L[i])
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
k -= 1
ans = 1 << 99
for i in range(n - k):
	ans = min(ans, abs(a[i]) + a[k + i] - a[i], abs(a[k + i]) + a[k + i] - a[i])
print(ans)


(n, k) = map(int, input().split())
al = list(map(int, input().split()))
res = 10 ** 10
for i in range(n - k + 1):
	st = al[i]
	en = al[i + k - 1]
	if st * en < 0:
		temp = min(abs(st), abs(en)) * 2 + max(abs(st), abs(en))
	else:
		temp = max(abs(st), abs(en))
	res = min(temp, res)
print(res)


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
d = 10 ** 9
for i in range(b - 1, a):
	e = abs(c[i] - c[i - b + 1])
	e += min(abs(c[i]), abs(c[i - b + 1]))
	d = min(d, e)
print(d)


from bisect import bisect_left
import sys
input = sys.stdin.readline
(N, K) = map(int, input().split())
x = list(map(int, input().split()))
x_shift = [i + abs(x[0]) for i in x]
dist = []
for i in range(N - K + 1):
	d_end = x_shift[i + K - 1] - x_shift[i]
	d_left = abs(x[i])
	d_right = abs(x[i + K - 1])
	dist.append(d_end + min(d_left, d_right))
print(min(dist))


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
tp = N
for i in range(N):
	if x[i] >= 0:
		tp = i
		break
	x[i] *= -1
s = max(0, tp - K + 1)
g = min(tp - 1, N - K)
ans = float('INF')
if K <= tp:
	ans = min(ans, x[tp - K])
if K <= N - tp:
	ans = min(ans, x[tp + K - 1])
for i in range(s, g + 1):
	ans = min(ans, x[i] + x[i + K - 1] + min(x[i], x[i + K - 1]))
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
g = 999999999
for i in range(N - K + 1):
	g = min(g, x[K - 1 + i] - x[i] + min(abs(x[K - 1 + i]), abs(x[i])))
print(g)


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
ne_lst = []
po_lst = []
for i in lst:
	if i < 0:
		ne_lst.append(-i)
	else:
		po_lst.append(i)
ne_lst.reverse()
res = 10 ** 10
if len(ne_lst) >= k:
	res = min(res, ne_lst[k - 1])
if len(po_lst) >= k:
	res = min(res, po_lst[k - 1])
for (i, j) in enumerate(ne_lst):
	if k - (i + 1) > 0 and len(po_lst) > k - 1 - (i + 1):
		res = min(res, ne_lst[i] * 2 + po_lst[k - 1 - (i + 1)])
for (i, j) in enumerate(po_lst):
	if k - (i + 1) > 0 and len(ne_lst) > k - 1 - (i + 1):
		res = min(res, po_lst[i] * 2 + ne_lst[k - 1 - (i + 1)])
print(res)


(n, k) = map(int, input().split())
xlist = list(map(int, input().split()))
ans = 10 ** 20
for i in range(n - k + 1):
	ans = min(abs(xlist[i] - xlist[i + k - 1]) + min(abs(xlist[i]), abs(xlist[i + k - 1])), ans)
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9
for i in range(n - k + 1):
	t = min(abs(x[i]), abs(x[i + k - 1]))
	ans = min(ans, t + abs(x[i] - x[i + k - 1]))
print(ans)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10 ** 9
for l in range(n - k + 1):
	r = l + k - 1
	ans = min(ans, abs(x[r]) + abs(x[r] - x[l]), abs(x[l]) + abs(x[r] - x[l]))
print(ans)


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 10000000000000
for i in range(n - k + 1):
	ans1 = abs(l[i]) + abs(l[i + k - 1] - l[i])
	ans2 = abs(l[i + k - 1]) + abs(l[i + k - 1] - l[i])
	ans = min(ans, ans1, ans2)
print(ans)


(N, K) = map(int, input().split())
(*X,) = map(int, input().split())
i = 0
ans = []
while i + K - 1 < N:
	(a, b) = (X[i], X[i + K - 1])
	if b < 0:
		ans.append(abs(a))
	elif a > 0:
		ans.append(b)
	else:
		a = abs(a)
		ans.append(a + b + min(a, b))
	i += 1
print(min(ans))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
	ans = min(ans, abs(x[i]) + abs(x[i] - x[i + k - 1]), abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]))
print(ans)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
s = 10 ** 9
for i in range(n - k + 1):
	if x[i] * x[i + k - 1] >= 0:
		t = max(abs(x[i]), abs(x[i + k - 1]))
	else:
		t = abs(x[i]) + abs(x[i + k - 1]) + min(abs(x[i]), abs(x[i + k - 1]))
	s = min(s, t)
print(s)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = []
for j in range(n - k + 1):
	if x[j] > 0:
		ans.append(x[j + k - 1])
	elif x[j] <= 0 <= x[j + k - 1]:
		ans.append(min(2 * abs(x[j]) + x[j + k - 1], abs(x[j]) + 2 * x[j + k - 1]))
	else:
		ans.append(-x[j])
print(min(ans))


(N, K) = map(int, input().split())
x = [int(i) for i in input().split()]
ans = float('inf')
for i in range(N - K + 1):
	n = x[i + K - 1] - x[i]
	ans = min(ans, n + abs(x[i]), n + abs(x[i + K - 1]))
print(ans)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
import bisect
b = bisect.bisect_left(x, 0)
r = x[b:]
l = list(reversed(x[:b]))
R = len(r)
L = len(l)
ans = float('inf')
if k <= R:
	ans = min(ans, r[k - 1])
if k <= L:
	ans = min(ans, abs(l[k - 1]))
for i in range(R):
	if i < k and k - i - 2 <= L - 1 and (k - i - 2 >= 0):
		tmp = 2 * r[i] + abs(l[k - i - 2])
		ans = min(ans, tmp)
for j in range(L):
	if j < k and k - j - 2 <= R - 1 and (k - j - 2 >= 0):
		tmp = 2 * abs(l[j]) + r[k - j - 2]
		ans = min(ans, tmp)
print(ans)


(N, K) = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
print(min((r - l + min(abs(l), abs(r)) for (l, r) in zip(X, X[K - 1:]))))


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
a = N - K + 1
long = 10 ** 9
for i in range(a):
	l = A[i + K - 1] - A[i] + min(abs(A[i + K - 1]), abs(A[i]))
	long = min(long, l)
print(long)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
p = True
for i in range(N):
	if X[i] < 0:
		continue
	elif X[i] == 0:
		K -= 1
		if i < K:
			mX = [0] + [-x for x in X[:i]][::-1]
		else:
			mX = [0] + [-x for x in X[i - K:i]][::-1]
		pX = [0] + X[i + 1:i + 1 + K]
		p = False
		break
	else:
		if i < K:
			mX = [0] + [-x for x in X[:i]][::-1]
		else:
			mX = [0] + [-x for x in X[i - K:i]][::-1]
		pX = [0] + X[i:i + K]
		p = False
		break
if p:
	mX = [0] + [-x for x in X[::-1]]
	pX = [0]
ans = 10 ** 9
l = K - (len(pX) - 1)
n = len(mX)
for i in range(len(pX) - 1, -1, -1):
	if l < n:
		ans = min(ans, pX[i] + mX[l] * 2, pX[i] * 2 + mX[l])
	else:
		break
	l += 1
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
A = []
for n in range(N - K + 1):
	A += [X[n + K - 1] - X[n] + min(abs(X[n]), abs(X[n + K - 1]))]
print(min(A))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
a = []
for i in range(0, n - k + 1):
	a.append(min(abs(l[i]) + abs(l[i] - l[i + k - 1]), abs(l[i + k - 1]) + abs(l[i] - l[i + k - 1])))
print(min(a))


url = 'https://atcoder.jp//contests/abc107/tasks/arc101_a'

def main():
	(n, k) = list(map(int, input().split()))
	xs = list(map(int, input().split()))
	ans = 100000000000000
	se = [0, k - 1]
	while se[1] < n:
		if xs[se[0]] < 0 <= xs[se[1]]:
			tmp = min(abs(xs[se[0]]), xs[se[1]]) * 2 + max(abs(xs[se[0]]), xs[se[1]])
			ans = min(ans, tmp)
		elif xs[se[0]] < 0:
			ans = min(ans, abs(xs[se[0]]))
		elif xs[se[1]] >= 0:
			ans = min(ans, xs[se[1]])
		se = [v + 1 for v in se]
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
x = [int(i) for i in input().split()]
ans = 10 ** 9
for i in range(n - k + 1):
	temp = 0
	temp += min(abs(x[i]), abs(x[i + k - 1])) + abs(x[i] - x[i + k - 1])
	ans = min(ans, temp)
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
ans = min([min(abs(x[i]) + abs(x[i] - x[i + K - 1]), abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i])) for i in range(N - K + 1)])
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
res = []
for i in range(N - K + 1):
	tmp = min(abs(x[i]), abs(x[i + K - 1])) + x[i + K - 1] - x[i]
	res.append(tmp)
print(min(res))


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
ans = 10 ** 9
for i in range(n - k + 1):
	l = X[i]
	r = X[i + k - 1]
	tmp = min(abs(l) + abs(l - r), abs(r) + abs(l - r))
	ans = min(tmp, ans)
print(ans)


(N, K) = list(map(int, input().split()))
X = list(map(int, input().split()))
ans = 10 ** 9
for i in range(N - K + 1):
	if X[i] >= 0:
		ans = min(ans, X[K + i - 1])
	elif X[K + i - 1] <= 0:
		ans = min(ans, -X[i])
	else:
		ans = min(ans, 2 * X[K + i - 1] - X[i], X[K + i - 1] - 2 * X[i])
print(ans)


def resolve():
	(N, K) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	ans = 1 << 60
	for i in range(N - K + 1):
		l = A[i]
		r = A[i + K - 1]
		l_to_r = abs(l) + abs(l - r)
		r_to_l = abs(r) + abs(r - l)
		res = min(l_to_r, r_to_l)
		ans = min(ans, res)
	print(ans)

def __starting_point():
	resolve()
__starting_point()


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
ans = pow(10, 9) + 7
for i in range(n - k + 1):
	ans = min(ans, min(abs(X[i]) + abs(X[i + k - 1] - X[i]), abs(X[i + k - 1]) + abs(X[i] - X[i + k - 1])))
print(ans)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(N, K, *X) = list(map(int, read().split()))
	A = [abs(x - X[0]) for x in X]
	ans = INF
	for i in range(N - K + 1):
		if ans > min(abs(X[i]), abs(X[i + K - 1])) + A[i + K - 1] - A[i]:
			ans = min(abs(X[i]), abs(X[i + K - 1])) + A[i + K - 1] - A[i]
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(n, k, *a) = map(int, open(0).read().split())
ans = 10 ** 9
for i in range(n - k + 1):
	(b, c) = (a[i], a[i + k - 1])
	ans = min(ans, min(abs(b), abs(c)) + abs(b - c))
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = float('inf')
for l in range(N + 1 - K):
	r = l + K - 1
	ans = min(ans, min(abs(X[l]), abs(X[r])) + X[r] - X[l])
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ret = 10 ** 20
for i in range(n - k + 1):
	left = x[i]
	right = x[i + k - 1]
	ret = min(ret, min(abs(left), abs(right)) + right - left)
print(ret)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = 1e+20
for i in range(N - K + 1):
	ans = min(ans, X[i + K - 1] - X[i] + abs(X[i]))
	ans = min(ans, X[i + K - 1] - X[i] + abs(X[i + K - 1]))
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = 10 ** 9
for i in range(N - K + 1):
	ans = min(ans, X[i + K - 1] - X[i] + min(abs(X[i]), abs(X[i + K - 1])))
print(ans)


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
V = []
for i in range(n - k + 1):
	Y = X[i + k - 1] - X[i]
	V.append(Y + min(abs(X[i]), abs(X[i + k - 1])))
print(min(V))


(n, k, *x) = list(map(int, open(0).read().split()))
ans = 10 ** 18
neg = [i for i in x if i < 0] + [0]
pos = [0] + [i for i in x if i >= 0]
l = len(neg) - max(0, k + 1 - len(pos))
r = min(k + 1, len(pos))
while l > 0 and r > 0:
	l -= 1
	r -= 1
	ans = min(ans, -neg[l] * 2 + pos[r], -neg[l] + pos[r] * 2)
print(ans)


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
ans = float('inf')
for i in range(N - K + 1):
	ans = min(ans, A[i + K - 1] - A[i] + min(abs(A[i + K - 1]), abs(A[i])))
print(ans)


(N, K) = map(int, input().split())
(*X,) = map(int, input().split())
import bisect
i = bisect.bisect_left(X, 0)
L = max(0, bisect.bisect_right(X, 0) - K)
R = min(N - 1, bisect.bisect_left(X, 0) + K - 1)
ans = float('inf')
for i in range(L, R - K + 2):
	t = 0
	l = X[i]
	r = X[i + K - 1]
	if r <= 0:
		t = abs(l)
	elif 0 <= l:
		t = r
	else:
		t = min(abs(l), r) * 2 + max(abs(l), r)
	ans = min(ans, t)
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
time = 100000000000
for i in range(n - k + 1):
	l = x[i]
	r = x[i + k - 1]
	time = min(time, abs(l) + r - l, abs(r) + r - l)
print(time)


(N, K, *x) = map(int, open(0).read().split())
ans = 1000000000.0
for i in range(N - K + 1):
	l = x[i]
	r = x[i + K - 1]
	ans = min(ans, abs(l) + (r - l), abs(r) + (r - l))
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 17
for i in range(N - K + 1):
	(l, r) = (i, i + K - 1)
	ans = min(abs(x[r]) + abs(x[l] - x[r]), min(ans, abs(x[l]) + abs(x[r] - x[l])))
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
res = 10 ** 16
for i in range(len(x) - k + 1):
	res = min(res, abs(x[i]) + abs(x[i + k - 1] - x[i]), abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]))
print(res)


(n, k, *x) = map(int, open(0).read().split())
print(min([min(abs(x[i]), abs(x[i + k - 1])) + (x[i + k - 1] - x[i]) for i in range(n - k + 1)]))


(N, K) = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
ans = float('inf')
for i in range(N - K + 1):
	left = X[i]
	right = X[i + K - 1]
	if left * right >= 0:
		ans = min(ans, max(abs(left), right))
	else:
		ans = min(ans, right - left + min(abs(left), right))
print(ans)


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
if len(lis) == 1:
	print(abs(lis[0]))
	return
ans = 10 ** 9 + 7
for i in range(n - k + 1):
	l = abs(lis[i]) + abs(lis[i + k - 1] - lis[i])
	r = abs(lis[i + k - 1]) + abs(lis[i + k - 1] - lis[i])
	ans = min(ans, l, r)
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9 + 7
for i in range(n - k + 1):
	temp = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1]))
	if temp < ans:
		ans = temp
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
min_len = 1000000000.0
for i in range(n - k + 1):
	min_len = min(min_len, x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1])))
print(min_len)


(N, K) = list(map(int, input().split()))
x = list(map(int, input().split()))
l = []
for i in range(N - K + 1):
	left = i
	right = i + K - 1
	ans1 = abs(x[left]) + abs(x[right] - x[left])
	ans2 = abs(x[right]) + abs(x[right] - x[left])
	tmp_ans = min(ans1, ans2)
	l.append(tmp_ans)
ans = min(l)
print(ans)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def lcm(a: int, b: int) -> int:
	return a * b // math.gcd(a, b)

def Main():
	(n, k) = read_ints()
	x = read_int_list()
	ans = INF
	for i in range(n - k + 1):
		left = x[i]
		right = x[i + k - 1]
		if left < 0 and right > 0:
			ans = min(ans, min(abs(left), abs(right)) * 2 + max(abs(left), abs(right)))
		else:
			ans = min(ans, max(abs(left), abs(right)))
	print(ans)

def __starting_point():
	Main()
__starting_point()


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans_ar = []
for i in range(N - K + 1):
	ans_ar.append(min(abs(X[i]), abs(X[i + K - 1])) + (X[i + K - 1] - X[i]))
print(min(ans_ar))


(n, k) = list(map(int, input().split()))
xlst = list(map(int, input().split()))
minus = []
plus = []
for x in xlst:
	if x < 0:
		minus.append(-1 * x)
	elif x > 0:
		plus.append(x)
	else:
		k -= 1
if k == 0:
	print(0)
	return
minus.append(0)
minus = minus[::-1]
plus = [0] + plus
ans = 10 ** 20
ml = len(minus)
pl = len(plus)
pos = min(k, ml - 1)
while 1:
	mm = minus[pos]
	pp = plus[k - pos]
	ans_tmp = max(mm, pp) + min(mm, pp) * 2
	ans = min(ans, ans_tmp)
	pos -= 1
	if pos == -1 or k - pos == pl:
		break
print(ans)


from bisect import bisect_left
(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
pos = bisect_left(x, 0)
if pos < len(x) and x[pos] == 0:
	k -= 1
else:
	x.insert(pos, 0)
l = pos
r = pos + k
if r >= len(x):
	diff = r - len(x) + 1
	l -= diff
	r -= diff
ans = min(abs(x[l]), x[r]) * 2 + max(abs(x[l]), x[r])
while r >= pos:
	if l < 0:
		break
	dist = min(abs(x[l]), x[r]) * 2 + max(abs(x[l]), x[r])
	if dist < ans:
		ans = dist
	l -= 1
	r -= 1
print(ans)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
x = []
for i in range(n - k + 1):
	y = a[i + k - 1] - a[i] + min(abs(a[i + k - 1]), abs(a[i]))
	x.append(y)
print(min(x))


(n, k) = map(int, input().split())
c = list(map(int, input().split()))
ans = float('Inf')
for i in range(n - k + 1):
	(l, r) = (c[i], c[i + k - 1])
	ans = min(abs(l) + abs(r - l), abs(r) + abs(r - l), ans)
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
ans = 1000000000.0
for i in range(N - K + 1):
	l = x[i]
	r = x[i + K - 1]
	ans = min(ans, abs(l) + abs(r - l), abs(r) + abs(l - r))
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 4 * 10 ** 8
for (a, b) in zip(x, x[k - 1:]):
	cand = b - a + min(abs(a), abs(b))
	ans = min(cand, ans)
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
m = 10 ** 9
for i in range(n - k + 1):
	a = l[i]
	b = l[i + k - 1]
	m = min(m, b - a + min(abs(a), abs(b)))
print(m)


import math
(N, K) = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
	if x[i] == 0:
		(p, m) = (i, i + 1)
		break
	elif x[i] > 0:
		(p, m) = (i, i)
		break
if x[0] < 0 and x[-1] > 0:
	pls = x[p:]
	mns = x[:m]
	ans = math.inf
	for i in range(len(pls)):
		if i < K - 1:
			if pls[0] == 0:
				n = K - i
			else:
				n = K - i - 1
			if len(mns) >= n:
				tmp = 2 * abs(mns[-n]) + pls[i]
				ans = min(ans, tmp)
		if i == K - 1:
			ans = min(ans, pls[i])
			break
	for i in range(len(mns)):
		m = len(mns) - i
		if m < K:
			if pls[0] == 0:
				n = K - m
			else:
				n = K - m - 1
			if len(pls) > n:
				tmp = 2 * pls[n] + abs(mns[-m])
				ans = min(ans, tmp)
		if m == K:
			ans = min(ans, abs(mns[i]))
elif x[0] >= 0:
	ans = x[K - 1]
else:
	ans = abs(x[-K])
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
T = 10 ** 18
for i in range(N - K + 1):
	if X[i + K - 1] <= 0:
		T = min(T, -X[i])
	elif X[i] >= 0:
		T = min(T, X[i + K - 1])
	else:
		T = min(T, X[i + K - 1] - X[i] + min(-X[i], X[i + K - 1]))
print(T)


(N, K) = list(map(int, input().split()))
X_list = list(map(int, input().split()))
INF = 10 ** 18
ans = INF
import bisect
zero_index = bisect.bisect_left(X_list, 0)
candidate_list = []
ans = INF
for i in range(K + 1):
	head = zero_index - i
	tail = head + K - 1
	if head < 0 or tail > N - 1:
		continue
	if i == 0:
		ans = min(ans, abs(X_list[tail]))
	elif i == K:
		ans = min(ans, abs(X_list[head]))
	else:
		head_abs = abs(X_list[head])
		tail_abs = abs(X_list[tail])
		ans = min(ans, head_abs + tail_abs + min(head_abs, tail_abs))
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(abs, x))
ans = float('inf')
for i in range(n - k + 1):
	if 0 < x[i] * x[i + k - 1]:
		cost = max(y[i], y[i + k - 1])
	else:
		cost = y[i] + y[i + k - 1] + min(-x[i], x[i + k - 1])
	ans = min(ans, cost)
print(ans)


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
b = []
dis = N - K + 1
for i in range(dis):
	b.append(min(abs(a[i]) + abs(a[i] - a[i + K - 1]), abs(a[i + K - 1]) + abs(a[i + K - 1] - a[i])))
print(min(b))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
ans = float('inf')
for i in range(n - k + 1):
	(l, r) = (i, i + k - 1)
	ans = min(ans, abs(A[r] - A[l]) + abs(A[r]), abs(A[l]) + abs(A[l] - A[r]))
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
m = float('INF')
for i in range(N - K + 1):
	m = min(m, x[i + K - 1] - x[i] + min(abs(x[i + K - 1]), abs(x[i])))
print(m)


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
m = 10 ** 9
for i in range(n - k + 1):
	m = min(m, abs(X[i]) + abs(X[i + k - 1] - X[i]), abs(X[i + k - 1]) + abs(X[i] - X[i + k - 1]))
print(m)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
k = float('INF')
for i in range(N - K + 1):
	l = X[i]
	r = X[i + K - 1]
	k = min(k, abs(l) + abs(r - l), abs(r) + abs(r - l))
print(k)


(N, K) = list(map(int, input().split()))
X = list(map(int, input().split()))
a = []
for i in range(N - K + 1):
	l = X[i]
	r = X[i + K - 1]
	a.append(min(abs(l) + abs(r - l), abs(r) + abs(r - l)))
print(min(a))


import math
import bisect
import numpy as np
(N, k) = list(map(int, input().split()))
X = list(map(int, input().split()))
ans = float('inf')
for i in range(N - k + 1):
	a = X[i]
	b = X[i + k - 1]
	if np.sign(a) * np.sign(b) >= 0:
		ans = min(ans, max(abs(a), abs(b)))
	else:
		ans = min(ans, abs(a) + abs(b) + min(abs(a), abs(b)))
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
m = min((b - a + min(abs(a), abs(b)) for (a, b) in zip(x, x[K - 1:])))
print(m)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
mi = 10 ** 18
for i in range(N - K + 1):
	l = x[i]
	r = x[i + K - 1]
	lr = abs(l) + abs(l - r)
	rl = abs(r) + abs(l - r)
	mi = min(mi, min(lr, rl))
print(mi)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
minus = [0]
plus = [0]
for i in x:
	if x:
		plus.append(x)
	else:
		minus.append(-x)
k -= 1
ans = 1000000000000000
for i in range(n - k):
	if x[i + k] < 0:
		ans = min(ans, -x[i])
	elif 0 < x[i + k] and x[i] < 0:
		if -x[i] < x[i + k]:
			ans = min(ans, abs(2 * x[i]) + x[i + k])
		else:
			ans = min(ans, 2 * x[i + k] + abs(x[i]))
	else:
		ans = min(ans, x[i + k])
print(ans)


(n, k) = map(int, input().split())
xxx = list(map(int, input().split()))
print(min((min(abs(l), abs(r)) + r - l for (l, r) in zip(xxx, xxx[k - 1:]))))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
c = 10 ** 9
for i in range(n - k + 1):
	a = x[i + k - 1]
	b = x[i]
	if a < 0:
		c = min(c, abs(b))
	elif b < 0:
		c = min(c, min(a, abs(b)) * 2 + max(a, abs(b)))
	else:
		c = min(c, a)
print(c)


def main():
	(n, k) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	(m, p) = ([], [])
	for i in range(n):
		if x[i] < 0:
			m.append(x[i])
		else:
			p.append(x[i])
	(M, P) = (len(m), len(p))
	ans = float('inf')
	for i in range(min(M + 1, k + 1)):
		t = 0
		if i > 0:
			t += 2 * abs(m[M - i])
		r = k - i
		if r == 0:
			if t // 2 < ans:
				ans = t // 2
		elif r <= P:
			t += p[r - 1]
			if t < ans:
				ans = t
	for i in range(min(P + 1, k + 1)):
		t = 0
		if i > 0:
			t += 2 * p[i - 1]
		r = k - i
		if r == 0:
			if t // 2 < ans:
				ans = t // 2
		elif r <= M:
			t += abs(m[M - r])
			if t < ans:
				ans = t
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
v = 1000000000.0
for l in range(n - k + 1):
	r = l + k - 1
	a = abs(x[l]) + abs(x[l] - x[r])
	b = abs(x[r]) + abs(x[l] - x[r])
	v = min(v, min(a, b))
print(v)


(n, k, *a) = map(int, open(0).read().split())
print(min((r - l + min(abs(r), abs(l)) for (l, r) in zip(a, a[k - 1:]))))


(N, K) = list(map(int, input().split()))
x = list(map(int, input().split()))
minTime = 10000000000
for i in range(N - K + 1):
	time = 0
	minValue = x[i]
	maxValue = x[i + K - 1]
	if minValue < 0 and maxValue < 0:
		time = minValue * -1
	elif minValue >= 0 and maxValue >= 0:
		time = maxValue
	elif minValue < 0 and maxValue >= 0:
		leftTime = minValue * -1
		rightTime = maxValue
		if leftTime < rightTime:
			time = leftTime * 2 + rightTime
		else:
			time = leftTime + rightTime * 2
	if time < minTime:
		minTime = time
print(minTime)


(n, k) = map(int, input().split())
x = [int(i) for i in input().split()]
m = 4 * 10 ** 8
for i in range(n - k + 1):
	m = min(m, x[k - 1 + i] - x[i] + min(abs(x[k - 1 + i]), abs(x[i])))
print(m)


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
ans = 10 ** 13
for i in range(n - k + 1):
	ans = min(X[i + k - 1] - X[i] + min(abs(X[i + k - 1]), abs(X[i])), ans)
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n - k + 1):
	tmp = min(abs(a[k + i - 1] - a[i]) + abs(a[i]), abs(a[k + i - 1] - a[i]) + abs(a[k + i - 1]))
	if ans > tmp:
		ans = tmp
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n - k + 1):
	(s, e) = (x[i], x[i + k - 1])
	ans = min(ans, abs(s) + abs(e - s), abs(e) + abs(e - s))
print(ans)


(n, k, *l) = map(int, open(0).read().split())
m = 10000000000.0
for (i, j) in zip(l, l[k - 1:]):
	if i * j < 0:
		m = min(m, -i * 2 + j, -i + j * 2)
	else:
		m = min(m, max(abs(i), abs(j)))
print(m)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 4 * 10 ** 8
for i in range(n - k + 1):
	diff = x[i + k - 1] - x[i]
	ans = min(abs(x[i]) + diff, abs(x[i + k - 1]) + diff, ans)
print(ans)


(n, k, *a) = map(int, open(0).read().split())
m = INF = float('inf')
for i in range(n - k + 1):
	(l, r) = (a[i], a[i + k - 1])
	c = abs(r - l)
	m = min(m, min(abs(l) + c, abs(r) + c))
print(m)


(N, K) = map(int, input().split())
X = [int(x) for x in input().split()]
ans = 10 ** 10
for i in range(N - K + 1):
	tmp = X[i + K - 1] - X[i] + min(abs(X[i + K - 1]), abs(X[i]))
	if tmp < ans:
		ans = tmp
print(ans)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
for i in range(n - k + 1):
	dist = a[i + k - 1] - a[i] + min(abs(a[i]), abs(a[i + k - 1]))
	b.append(dist)
print(min(b))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
neg_num = n
for i in range(n):
	if x[i] > 0:
		neg_num = i
		break
pos_num = n - neg_num
l = min(k, neg_num)
res = 10 ** 13
for i in range(l, -1, -1):
	r = k - i
	if r <= pos_num:
		l_val = min(0, x[neg_num - i])
		r_val = max(0, x[neg_num + k - i - 1])
		tmp = min(-l_val * 2 + r_val, -l_val + r_val * 2)
		res = min(tmp, res)
print(res)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 1000000000.0
for i in range(len(x) - k + 1):
	l = abs(x[i + k - 1] - x[i]) + min(abs(x[i]), abs(x[i + k - 1]))
	ans = min(ans, l)
print(ans)


(N, K) = map(int, input().split())
x = [int(i) for i in input().split()]
cost = []
for i in range(N - K + 1):
	length = abs(x[i] - x[i + K - 1])
	cost.append(length + abs(x[i]))
	cost.append(length + abs(x[i + K - 1]))
print(min(cost))


(n, k) = list(map(int, input().split()))
pos = list(map(int, input().split()))
ans = 10 ** 13
for i in range(n - k + 1):
	a1 = abs(pos[i]) + abs(pos[i] - pos[i + k - 1])
	a2 = abs(pos[i + k - 1]) + abs(pos[i] - pos[i + k - 1])
	ans = min(ans, a1, a2)
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
tmp = []
for (l, r) in zip(X, X[K - 1:]):
	tmp.append(r - l + min(abs(l), abs(r)))
print(min(tmp))


(n, k) = map(int, input().split())
c = list(map(int, input().split()))
ans = 10 ** 100
for i in range(n - k + 1):
	(l, r) = (i, i + k - 1)
	d = min(abs(c[l]), abs(c[r])) + abs(c[l] - c[r])
	if d < ans:
		ans = d
print(ans)


def main():
	(_, k) = 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:]))))
main()


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
a = 10 ** 9
for i in range(n - k + 1):
	d = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1]))
	a = min(a, d)
print(a)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 10 ** 10
for i in range(n - k + 1):
	c = min(c, -a[i] + a[i + k - 1] + min(abs(a[i]), abs(a[i + k - 1])))
print(c)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = []
for i in range(N - K + 1):
	xl = X[i]
	xr = X[i + K - 1]
	ans.append(min(abs(xl) + abs(xr - xl), abs(xr) + abs(xl - xr)))
print(min(ans))


from sys import stdin

def getval():
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	return (n, k, x)

def main(n, k, x):
	idx = k - 1
	ans = 0
	if x[0] >= 0:
		ans = x[idx]
	elif x[idx] <= 0:
		ans = abs(x[0])
	else:
		ans = min(abs(x[0]), abs(x[idx])) * 2 + max(abs(x[0]), abs(x[idx]))
	for i in range(k, n):
		temp = 0
		if x[i - k + 1] >= 0:
			temp = x[i]
		elif x[i] <= 0:
			temp = abs(x[i - k + 1])
		else:
			temp = min(abs(x[i]), abs(x[i - k + 1])) * 2 + max(abs(x[i]), abs(x[i - k + 1]))
		ans = min(ans, temp)
	print(ans)

def __starting_point():
	(n, k, x) = getval()
	main(n, k, x)
__starting_point()


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
inf = 10 ** 12
z = len(x)
if n == 1 and k == 1:
	print(0)
	return
for i in range(len(x)):
	if x[i] >= 0:
		z = i
		break
r = [inf] * (n - z)
l = [inf] * z
for i in range(n - z):
	r[i] = x[z + i]
for i in range(z):
	l[i] = abs(x[z - i - 1])
tl = inf
if len(l) < k:
	tl = inf
else:
	tl = abs(l[k - 1])
if z == n - 1:
	print(tl)
	return
tr = inf
if len(r) < k:
	tr = inf
else:
	tr = abs(r[k - 1])
t_arr = []
for i in range(1, k):
	if i - 1 >= len(r):
		pass
	elif k - i - 1 >= len(l):
		pass
	else:
		t1 = r[i - 1]
		t2 = l[k - i - 1]
		t_arr.append(t1 * 2 + t2 * 2 - max(t1, t2))
tc = inf
if len(t_arr) != 0:
	tc = min(t_arr)
else:
	tc = inf
print(min(tl, tr, tc))


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
a = [x[i] for i in range(n) if x[i] < 0]
b = [x[i] for i in range(n) if x[i] >= 0]
na = len(a)
nb = len(b)
if 0 in x:
	k -= 1
	b = [x[i] for i in range(n) if x[i] > 0]
	nb = nb - 1
if k == 0:
	print(0)
	return
ans = 10 ** 10
if na >= k:
	ans = -a[-k]
if nb >= k:
	ans = min(ans, b[k - 1])
if nb == 0:
	print(-a[-k])
	return
if na == 0:
	print(b[k - 1])
	return
for i in range(1, nb + 1):
	m = k - i
	if m > na or m < 0:
		continue
	elif 0 < m <= na:
		ans = min(ans, min(b[i - 1] - 2 * a[-m], 2 * b[i - 1] - a[-m]))
	elif m == 0:
		ans = min(ans, b[k - 1])
print(ans if k != 0 else 0)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 20
for i in range(n - k + 1):
	dist = x[k + i - 1] - x[i] + min(abs(x[k + i - 1]), abs(x[i]))
	if ans > dist:
		ans = dist
print(ans)


(N, K) = map(int, input().split())
l = list(map(int, input().split()))
D = [l[i + K - 1] - l[i] + min(abs(l[i + K - 1]), abs(l[i])) for i in range(N - K + 1)]
print(min(D))


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
ans = []
for l in range(n - k + 1):
	r = l + k - 1
	ans.append(min(abs(X[l]) + abs(X[l] - X[r]), abs(X[r]) + abs(X[r] - X[l])))
print(min(ans))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
c = 10 ** 9
for i in range(n - k + 1):
	h = x[i]
	m = x[i + k - 1]
	H = abs(h)
	M = abs(m)
	if h * m < 0:
		c = min(c, 2 * H + M, 2 * M + H)
	else:
		c = min(c, max(M, H))
print(c)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
a = []
for i in range(n - k + 1):
	a1 = abs(x[i]) + abs(x[i + k - 1] - x[i])
	a2 = abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i])
	a.append(min(a1, a2))
print(min(a))


(n, K) = (int(i) for i in input().strip().split(' '))
x = [int(i) for i in input().strip().split(' ')]
ans = min((b - a + min(abs(a), abs(b)) for (a, b) in zip(x, x[K - 1:])))
print(ans)


(n, k, *l) = map(int, open(0).read().split())
print(min(((max(abs(i), abs(j)), min(-i * 2 + j, -i + 2 * j))[i * j < 0] for (i, j) in zip(l, l[k - 1:]))))


(N, K) = map(int, input().split())
x = [int(i) for i in input().split()]
key = []
for (left, right) in zip(x, x[K - 1:]):
	key.append(right - left + min(abs(left), abs(right)))
print(min(key))


(N, K) = list(map(int, input().split()))
D = [int(n) for n in input().split()]
ans = 10000000000
for i in range(N - K + 1):
	L = D[i]
	R = D[i + K - 1]
	LR = abs(L) + abs(L - R)
	RL = abs(R) + abs(R - L)
	ans = min(ans, min(LR, RL))
print(ans)


import bisect
import math
(N, K) = map(int, input().split())
X = list(map(int, input().split()))
a = bisect.bisect_left(X, 0)
X.insert(a, 0)
ans = math.inf
for i in range(max(0, a + K - N), min(a + 1, K + 1)):
	ans = min(ans, -X[a - i] * 2 + X[a + K - i], -X[a - i] + X[a + K - i] * 2)
print(ans)


(n, k, *a) = map(int, open(0).read().split())
ans = 100000000000.0
for i in range(n - k + 1):
	ans = min(ans, a[i + k - 1] - a[i] + min(abs(a[i + k - 1]), abs(a[i])))
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 10
for left in range(n - k + 1):
	right = left + k - 1
	ans = min(ans, abs(x[left]) + abs(x[right] - x[left]), abs(x[right]) + abs(x[right] - x[left]))
print(ans)


f = lambda : map(int, input().split())
(n, k) = f()
x = list(f())
d = 10 ** 9
for i in range(n - k + 1):
	(l, r) = (x[i], x[i + k - 1])
	d = [min(d, max(-l, r)), min(d, r - l + min(-l, r))][l < 0 < r]
print(d)


(N, K) = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
m = 10 ** 9
for i in range(N - K + 1):
	m = min(m, X[K - 1 + i] - X[i] + min(abs(X[K - 1 + i]), abs(X[i])))
print(m)


(n, k) = map(int, input().split())
list_X = list(map(int, input().split()))
ans = pow(10, 14)
for i in range(n - k + 1):
	if list_X[i] * list_X[i + k - 1] < 0:
		ans = min(ans, list_X[i + k - 1] - list_X[i] + min(abs(list_X[i]), abs(list_X[i + k - 1])))
	else:
		ans = min(ans, max(abs(list_X[i + k - 1]), abs(list_X[i])))
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
ans = []
for i in range(N - K + 1):
	if x[i] < 0 and x[i + K - 1] > 0:
		ans += (abs(x[i]) + abs(x[i + K - 1]) + min(abs(x[i]), abs(x[i + K - 1])),)
	elif x[i] < 0:
		ans += (-x[i],)
	else:
		ans += (x[i + K - 1],)
print(min(ans))


(N, K) = map(int, input().split())
x = [int(i) for i in input().split()]
ls = []
for (x, y) in zip(x[:N - K + 1], x[K - 1:]):
	ls.append(min(abs(x) + abs(x - y), abs(y) + abs(x - y)))
print(min(ls))


import numpy as np
(N, K) = list(map(int, input().split()))
X = np.array(input().split(), dtype=np.int64)
INF = 10 ** 18
neg = np.concatenate([-X[X <= 0][::-1], np.full(N + 1, INF, dtype=np.int64)])[:K]
pos = np.concatenate([X[X > 0], np.full(N + 1, INF, dtype=np.int64)])[:K]
answer = INF
answer = min(answer, neg[-1])
answer = min(answer, pos[-1])
if K >= 2:
	answer = min(answer, (neg[:K - 1] * 2 + pos[K - 2::-1]).min())
	answer = min(answer, (pos[:K - 1] * 2 + neg[K - 2::-1]).min())
print(answer)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 10 ** 9
for i in range(0, n - k + 1):
	if x[i] * x[i + k - 1] >= 0:
		ans_tmp = max(abs(x[i]), abs(x[i + k - 1]))
	else:
		ans_tmp = abs(x[i]) + abs(x[i + k - 1]) + min(abs(x[i]), abs(x[i + k - 1]))
	ans = min(ans, ans_tmp)
print(ans)


def solve(N, K, x):
	l = [abs(xi) for xi in x if xi < 0] + [0]
	l.reverse()
	r = [0] + [xi for xi in x if xi >= 0]
	ans = 10 ** 18 * 2 + 1
	for i in range(max(K - (len(l) - 1), 0), min(K + 1, len(r))):
		ll = l[K - i]
		rr = r[i]
		ans = min(ans, min(ll, rr) * 2 + max(ll, rr))
	print(ans)

def __starting_point():
	(N, K) = list(map(int, input().split()))
	x = [int(i) for i in input().split()]
	solve(N, K, x)
__starting_point()


(N, K) = map(int, input().split())
S = list(map(int, input().split()))
ans = float('inf')
if N == 1:
	ans = abs(S[0])
for i in range(N - K + 1):
	L = S[i]
	R = S[i + K - 1]
	ans = min(abs(L) + abs(R - L), abs(R) + abs(L - R), ans)
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = float('inf')
for i in range(0, n - k + 1):
	b = a[i]
	c = a[i + k - 1]
	if c <= 0:
		ans = min(ans, abs(b))
	elif b >= 0:
		ans = min(ans, abs(c))
	else:
		ans = min(ans, abs(c) + abs(b) * 2, abs(c) * 2 + abs(b))
print(ans)


(n, k, *x) = list(map(int, open(0).read().split()))
ans = 10 ** 18
neg = []
pos = [0]
for i in x:
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.append(0)
k += 1
c = len(neg)
c -= k - min(k, len(pos))
k = min(k, len(pos))
while c > 0 and k > 0:
	c -= 1
	k -= 1
	ans = min(ans, -neg[c] * 2 + pos[k], -neg[c] + pos[k] * 2)
print(ans)


(N, K) = map(int, input().split())
X = tuple(map(int, input().split()))
print(min((X[i + K - 1] - X[i] + min(abs(X[i]), abs(X[i + K - 1])) for i in range(N - K + 1))))


(n, k) = map(int, input().split())
x = [int(i) for i in input().split()]
d = []
for i in range(n - k + 1):
	(l, r) = (x[i], x[i + k - 1])
	d.append(abs(l - r) + min(abs(l), abs(r)))
print(min(d))


(N, K) = map(int, input().split())
cans = list(map(int, input().split()))
print(min([min(abs(cans[n]), abs(cans[n + (K - 1)])) + abs(cans[n + (K - 1)] - cans[n]) for n in range(N - K + 1)]))


(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
res = 10 ** 9
for i in range(n - m + 1):
	res = min(res, lis[i + m - 1] - lis[i] + min(abs(lis[i]), abs(lis[i + m - 1])))
print(res)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
v = []
for i in range(n - k + 1):
	a = abs(x[i]) + abs(x[i + k - 1] - x[i])
	b = abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])
	v.append(min(a, b))
print(min(v))


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
tmin = 1000000000
for i in range(N - K + 1):
	a = x[i + K - 1]
	b = x[i]
	res = a - b + min([abs(a), abs(b)])
	if tmin > res:
		tmin = res
print(tmin)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 18
for i in range(n - k + 1):
	a = abs(x[i + k - 1] - x[i])
	ans = min(ans, min(abs(x[i + k - 1]) + a, abs(x[i]) + a))
print(ans)


(N, K) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
ans = 10 ** 20
for i in range(N - K + 1):
	ans = min(ans, min(abs(x[i]) + abs(x[i + K - 1] - x[i]), abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1])))
print(ans)


(n, k) = map(int, input().split())
xs = list(map(int, input().split()))
m = float('inf')
for (l, r) in zip(xs, xs[k - 1:]):
	d = min(abs(l), abs(r)) + abs(r - l)
	m = min(m, d)
print(m)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ans = 1e+20
for i in range(n - k + 1):
	r = i + k - 1
	p1 = abs(l[i]) + abs(l[r] - l[i])
	p2 = abs(l[r]) + abs(l[i] - l[r])
	ans = min(ans, p1, p2)
print(ans)


(N, K) = map(int, input().split())
X = [int(x) for x in input().split()]
D = [X[i + K - 1] - X[i] + min(abs(X[i + K - 1]), abs(X[i])) for i in range(N - K + 1)]
print(min(D))


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
fst = 0
las = k - 1
dis = []
while las < n:
	dis.append(x[las] - x[fst] + min(abs(x[las]), abs(x[fst])))
	fst += 1
	las += 1
print(min(dis))


from collections import deque
(N, K) = map(int, input().strip().split())
x = list(map(int, input().strip().split()))
inf = 10 ** 9
l = inf
dp = deque(x[N - K:N])
i = 0
while True:
	if dp[0] >= 0:
		tmp = dp[K - 1]
	elif dp[K - 1] <= 0:
		tmp = -dp[0]
	elif abs(dp[K - 1]) >= abs(dp[0]):
		tmp = abs(dp[0]) * 2 + abs(dp[K - 1])
	else:
		tmp = abs(dp[K - 1]) * 2 + abs(dp[0])
	l = min(l, tmp)
	i += 1
	if N - K - i < 0:
		break
	else:
		dp.appendleft(x[N - K - i])
		dp.pop()
print(l)


def resolve():
	(N, K) = [int(item) for item in input().split()]
	xs = [int(item) for item in input().split()]
	min_lr = 10 ** 9
	min_rl = 10 ** 9
	if N != K:
		for i in range(N - K + 1):
			min_lr = min(min_lr, abs(xs[i]) + abs(xs[i + K - 1] - xs[i]))
			min_rl = min(min_rl, abs(xs[i + K - 1]) + abs(xs[i + K - 1] - xs[i]))
		print(min(min_lr, min_rl))
	elif N == 1:
		print(abs(xs[0]))
	else:
		print(min(abs(xs[0]) + abs(xs[N - 1] - xs[0]), abs(xs[N - 1]) + abs(xs[N - 1] - xs[0])))

def __starting_point():
	resolve()
__starting_point()


(N, K) = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 11
for i in range(N - K + 1):
	ans = min(ans, abs(a[i]) + a[i + K - 1] - a[i], abs(a[i + K - 1]) + a[i + K - 1] - a[i])
print(ans)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
ans = 1000000000.0
for (l, r) in zip(X, X[K - 1:]):
	ans = min(ans, r - l + min(abs(l), abs(r)))
print(ans)


(N, K) = map(int, input().split())
x = [int(i) for i in input().split()]
cost = 10 ** 13
for i in range(N - K + 1):
	c = x[i + K - 1] - x[i] + min(abs(x[i]), abs(x[i + K - 1]))
	cost = min(cost, c)
print(cost)


import sys
(N, K) = map(int, input().split())
lsx = list(map(int, input().split()))
if 0 in lsx:
	K = K - 1
	lsx.remove(0)
if bool(lsx) == False or K == 0:
	print(0)
	return
lshu = []
sei = len(lsx)
for i in range(len(lsx)):
	if lsx[i] < 0:
		lshu.append(lsx[i])
	else:
		sei = i
		break
lssei = lsx[sei:]
lenhu = len(lshu)
lensei = len(lssei)
lshu2 = [abs(lshu[i]) for i in range(lenhu - 1, -1, -1)]
dishu = [0] + lshu2
dissei = [0] + lssei
ans = 10 * 10 ** 8
for i in range(K + 1):
	if i <= lenhu and K - i <= lensei:
		ans = min(ans, 2 * dishu[i] + dissei[K - i], dishu[i] + 2 * dissei[K - i])
print(ans)


(N, K) = map(int, input().split())
x = list(map(int, input().split()))
Min = 10000000000.0
for i in range(N - K + 1):
	Min = min(Min, x[K + i - 1] - x[i] + min(abs(x[i]), abs(x[K + i - 1])))
print(Min)


(N, K) = map(int, input().split())
X = list(map(int, input().split()))
if N == 1:
	print(0)
	exit()
ans = float('Inf')
for i in range(N - K + 1):
	ans = min(ans, X[i + K - 1] - X[i] + min(abs(X[i + K - 1]), abs(X[i])))
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
neg_to_pos = n
for i in range(n):
	if x[i] > 0:
		neg_to_pos = i
		break
res = 10 ** 14
for i in range(n - k + 1):
	l = min(x[i], 0)
	r = max(0, x[i + k - 1])
	if i <= neg_to_pos and neg_to_pos - 1 <= i + k - 1:
		tmp = min(-2 * l + r, -l + 2 * r)
		res = min(res, tmp)
print(res)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 18
for l in range(n - k + 1):
	y = min(abs(x[l]) + abs(x[l + k - 1] - x[l]), abs(x[l + k - 1]) + abs(x[l + k - 1] - x[l]))
	ans = min(y, ans)
print(ans)