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

# 解説どおりのやりかた

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

ans = 0

for i in range(n - k + 1):
    tmp1 = (b[i] - b[0]) + (b[n] - b[i + k])
    tmp2 = tmp1 + (s[i + k] - s[i])
    ans = max(ans, tmp1, tmp2)

print(ans)