N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
	if A[i] > 0:
		ans += A[i]
		A[i] = 0
s = 0
t = 0
for a in A:
	if not a:
		t += 1
		s = 1
	else:
		t = 1
		s += 1
	if t >= K or s >= K:
		print(ans)
		exit()
m = sum(A[:K])
for i in range(N-K):
	M = m - A[i] + A[i+K]
	m = max(M,m)
print(max(ans+m,0))