N,K = list(map(int,input().split()))
a = list(map(int,input().split()))

S = [0]
s = 0
for i in range(N):
    s+=a[i]
    S.append(s)

S1 = [0]
s = 0

for i in range(N):
    s+=max(0,a[i])
    S1.append(s)
max_score=0
for i in range(N-K+1):
    max_score=max(S1[i]+max(S[i+K]-S[i],0) + S1[N]-S1[i+K],max_score)

print(max_score)