from itertools import accumulate
n,k,*a=map(int,open(0).read().split())
p=[x if x>0 else 0 for x in a]
acc=[0]+list(accumulate(a))
p_acc=[0]+list(accumulate(p))
rev_p_acc=[0]+list(accumulate(p[::-1]))
print(max(max(0,acc[k+i]-acc[i])+p_acc[i]+rev_p_acc[n-k-i] for i in range(n-k+1)))