n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
total=[0]*(n+1)
for i in xrange(n):
    if a[i]>0:
        total[i+1]=total[i]+a[i]
    else:
        total[i+1]=total[i]
ans=0
for i in xrange(n-k+1):
    tmp=0
    for j in xrange(i,i+k):
        tmp+=a[j]
    ans=max(ans,tmp+total[i]+total[n]-total[i+k],total[i]+total[n]-total[i+k])

print(ans)
