n,k=map(int,input().split())
#n=int(input())
a=[int(i) for i in input().split()]
acc=[0]*(n+1)
pos=[0]*(n+1)
for i in range(n):
    acc[i+1]+=a[i]
    pos[i+1]+=max(a[i],0)

ans=sum(a[0:k]+pos[k:])


for i in range(n-k):
    ans=max(ans,acc[i+k]-acc[i]+pos[i]+pos[-1]-pos[i+k])
    ans=max(ans,pos[i]+pos[-1]-pos[i+k])
print(ans)

