from itertools import accumulate
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
a = list(map(int, input().split()))
cum = list(accumulate([0, 0] + a))
left = [0] * (N+2)
for i in range(1, N+1):
    left[i] = left[i-1]
    if a[i-1] > 0:
        left[i] += a[i-1]
right = [0] * (N+2)
for i in range(1, N+1)[::-1]:
    right[i] = right[i+1]
    if a[i-1] > 0:
        right[i] += a[i-1]
ans = 0
for i in range(1, N-K+2):
    tmp = left[i-1] + right[i+K]
    if cum[i+K] - cum[i] > 0:
        tmp += cum[i+K] - cum[i]
    ans = max(ans, tmp)
print(ans)
