N,K = map(int, raw_input().split())
a = map(int, raw_input().split())

A = B = 0
for i in range(K):
    A += a[i]
for i in range(K, N):
    B += max(a[i], 0)
ans = max(A+B, B)
for i in range(N-K):
    A += a[i+K]-a[i]
    B += max(a[i], 0) - max(a[i+K], 0)
    ans = max(ans, A+B, B)
print ans
