N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [A[0]]
b = [max(A[0], 0)]
for i in range(N - 1):
    AS.append(AS[i] + A[i + 1])
    b.append(b[i] + max(A[i + 1], 0))
ans = -1
if N == 1 or N == K:
    ans = max(sum(A), 0)
for i in range(N - K):
    c = max(AS[i + K] - AS[i], 0)
    ans = max(ans, b[-1] - b[i + K] + b[i] + c)
print(ans)