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

a.insert(0, 0)
s = [0] * (n+1)
c = [0] * (n+1)

for i in range(1, n+1):
    s[i] = s[i-1] + a[i]
    c[i] = c[i-1] + max(a[i], 0)

res = 0
for i in range(1, n-k+2):
    res = max(res, c[i-1] + max(0, s[i+k-1]-s[i-1]) + c[n] - c[i+k-1])

print(res)