from itertools import accumulate
n,k=map(int,input().split())
l=list(map(int,input().split()))
b=[0 for i in range(n+1)]
h=[0 for i in range(n+1)]
for i,j in enumerate(l,1):
    if j>0:
        b[i]=j
    else:
        h[i]=-j
b,h=list(accumulate(b)),list(accumulate(h))
ma=b[-1]
ans=0
for i in range(n-k+1):
    ans=max(ans,ma-(b[i+k]-b[i]),ma-(h[i+k]-h[i]))
print(ans)