N,K=map(int,input().split())
a=[int(i) for i in input().split()]
S=[0]
p=[0]


for i in range(1,N+1):
  S.append(S[i-1]+a[i-1])
  if a[i-1]>0:
    p.append(p[i-1]+a[i-1])
  else:
    p.append(p[i-1])

ans=0
for i in range(1,N-K+2):
  res=0
  res+=max(S[i+K-1]-S[i-1],0)
  res+=p[i-1]
  res+=p[-1]-p[i+K-1]
  ans=max(res,ans)
print(ans)
  
  
  
     
    