from itertools import accumulate

n, k = map(int, input().split())
a = list(map(int, input().split()))

a_plus = [e if e > 0 else 0 for e in a]

acc = [0] + list(accumulate(a))
acc_plus = [0] + list(accumulate(a_plus))
ans = 0
for i in range(1, n - k + 2):
    white = acc_plus[i-1] + acc_plus[n] - acc_plus[i+k-1]
    black = white + acc[i+k-1] - acc[i-1]
    ans = max(ans, white, black)

print(ans)
