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

sumf[0]=(a[0]>=0)*a[0]
for i in range(1,N):
    sumf[i]=sumf[i-1]+(a[i]>=0)*a[i]

sumb[-1]=(a[-1]>=0)*a[-1]
for i in range(1,N):
    sumb[-i-1]=sumb[-i]+(a[-i-1]>=0)*a[-i-1]

s=sum(a[:K])
Ksum[0]=s
for i in range(1,N-K+1):
    s-=a[i-1]
    s+=a[i+K-1]
    Ksum[i]=s

ans=-float("inf")
for i in range(0,N-K+1):
    test=0
    if i!=0:
        test+=sumf[i-1]
    if i!=N-K:
        test+=sumb[i+K]
    test2=test
    test+=Ksum[i]

    ans=max(ans,test,test2)

print(ans)