n, k = map(int, input().split())
a = list(map(int, input().split()))
cumsum = [0]
cumsum_pos = [0]
for i in range(n):
	cumsum.append(cumsum[-1] + a[i])
	cumsum_pos.append(cumsum_pos[-1] + max(0, a[i]))
def range_sum(l, r):
	if l > r:
		return 0
	else:
		return cumsum[r + 1] - cumsum[l]
def range_pos(l, r):
	if l > r:
		return 0
	else:
		return cumsum_pos[r + 1] - cumsum_pos[l]

ans = -float("inf")

for i in range(n - k + 1):
	ans = max(ans, range_sum(i, i + k - 1) + range_pos(0, i - 1) + range_pos(i + k, n - 1), range_pos(0, i - 1) + range_pos(i + k, n - 1))

print(ans)