n,k=map(int,input().split())
a=list(map(int,input().split()))
maxans=0
sumplus=[0]
for i in range(n):
  if a[i]>0:
    maxans+=a[i]
  sumplus.append(maxans)
penalty=10**18
summinus=[0]
current=0
for i in range(n):
  if a[i]<0:
    current-=a[i]
  summinus.append(current)
for i in range(k,n+1):
  penalty=min(penalty,sumplus[i]-sumplus[i-k])
  penalty=min(penalty,summinus[i]-summinus[i-k])
print(maxans-penalty)
  
