n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
s1=[0]*n
s1[0]=a[0]
s2=[0]*n
if a[0]>0:
    s2[0]=a[0]
for i in xrange(1,n):
    s1[i]+=s1[i-1]+a[i]
    s2[i]+=s2[i-1]
    if a[i]>0:
        s2[i]+=a[i]
ans=-float("inf")
for i in xrange(n-k+1):
    if i==0:
        tmp1=s1[i+k-1]
        tmp2=s2[n-1]-s2[i+k-1]
    else:
        tmp1=s1[i+k-1]-s1[i-1]
        tmp2=s2[n-1]-(s2[i+k-1]-s2[i-1])
    ans=max(ans,tmp1+tmp2,tmp2)
print ans
