N,K=map(int,input().split())
a=[int(i) for i in input().split()]
b=[max([a[i],0]) for i in range(N)]
S=[0 for i in range(N+1)]
T=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+a[i]
    T[i+1]=T[i]+b[i]
ans=-10**15
for i in range(N-K+1):
    tmp=T[N]+S[i+K]-T[i+K]+T[i]-S[i]
    if ans<tmp:
        ans=tmp
for i in range(N-K+1):
    tmp=T[N]
    M=T[i+K]-T[i]
    tmp-=M
    if ans<tmp:
        ans=tmp
print(ans)

