n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
    c[i + 1] += c[i] + max(0, a[i])
s = sum(a[:k - 1])
ans = 0
for i in range(n - k + 1):
    s += a[i + k - 1]
    ans = max(ans, c[n] - c[i + k] + c[i] + max(0, s))
    s -= a[i]
print(ans)