n, k = map(int, raw_input().strip().split())
a = map(int, raw_input().strip().split())

sum_k = [0] * (n - k + 1)
pos_k = [0] * (n - k + 1)

pos_all = reduce(lambda x, y: x + y if y > 0 else x, a)

sum_k[0] = sum(a[:k])
pos_k[0] = reduce(lambda x, y: x + y if y > 0 else x, a[:k])

for i in range(1, n - k + 1):
	sum_k[i] = sum_k[i - 1] + a[i + k - 1] - a[i - 1]
	pos_k[i] = pos_k[i - 1] + (a[i + k - 1] if a[i + k - 1] > 0 else 0) - (a[i - 1] if a[i - 1] > 0 else 0)

result = 0

for i in range(n - k + 1):
	t = pos_all - pos_k[i] + (sum_k[i] if sum_k[i] > 0 else 0)
	if result < t:
		result = t

print result
