from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[max(0,i) for i in a]

a=[0]+list(accumulate(a))
b=[0]+list(accumulate(b))
s=b[-1]

print(max([max(a[i+k]-a[i],0)+s-b[i+k]+b[i] for i in range(n-k+1)]))