import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *

N, K = map(int, input().split())
a = list(map(int, input().split()))
f = [0] * (N+1)
for i in range(N):
    f[i+1] += f[i]+a[i]
g = [0] * (N+1)
for i in range(N):
    g[i+1] += g[i]+max(0, a[i])
ans = 0
for i in range(N-K+1):
    ans = max(ans, max(0, f[i+K]-f[i])+g[i]+g[N]-g[i+K])
print(ans)
