import sys
input = sys.stdin.readline

N, K = map(int, input().split())
a = list(map(int, input().split()))
acc1 = [0]
acc2 = [0]

for ai in a:
    acc1.append(acc1[-1]+ai)
    acc2.append(acc2[-1]+max(0, ai))

ans = 0

for i in range(N-K+1):
    ans = max(ans, max(0, acc1[i+K]-acc1[i])+acc2[i]+acc2[N]-acc2[i+K])

print(ans)