import sys
input = sys.stdin.readline
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
S,SS=[0]*(n+1),[0]*(n+1)
for i in range(n):
  S[i+1]=S[i]+A[i]
  SS[i+1]=SS[i]+max(0,A[i])
ans=-float("inf")
for i in range(n-k+1):
  ans=max(ans,SS[i]+SS[n]-SS[k+i]+max(0,S[k+i]-S[i]))
print(ans)