from itertools import accumulate as ac
n,k=map(int,input().split())
*l,=map(int,input().split())
*m,=map(lambda x:max(x,0),l)
*acc,=ac([0]+l)
v=0
for i in range(n-k+1):
  v=max(v,max(0,acc[i+k]-acc[i])+sum(m[i+k:])+sum(m[:i]))
print(v)