from itertools import accumulate
N, K = map(int, input().split())
A = []
B = []
for a in map(int, input().split()):
    A.append(a)
    B.append( a if a > 0 else 0)
S = [0]+list(accumulate(A))
T = [0]+list(accumulate(B))
res = 0
for i in range(N-K+1):
    res = max(T[i] + max(S[i+K] - S[i], 0) + T[N]-T[i+K], res)
print(res)