from itertools import accumulate as acc

N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[max(a[i],0) for i in range(N)]

A=list(acc(a))
B=list(acc(b))

ans=0
for i in range(N-K+1):
    if i==0: tmp=max(A[K-1],0)+(B[N-1]-B[K-1])
    elif i==N-K: tmp=B[N-K-1]+max(A[N-1]-A[N-K-1],0)
    else: tmp=B[i-1]+max(A[i+K-1]-A[i-1],0)+(B[N-1]-B[i+K-1])
    ans=max(ans,tmp)


print(ans)