N,K,*A = map(int, open(0).read().split())
m = sum(A[:K])
n = sum(c if c>0 else 0 for c in A[K:])
ans = max(m+n,n)
for i in range(N-K):
  m -= A[i]
  m += A[i+K]
  if A[i]>0:
    n += A[i]
  if A[i+K]>0:
    n -= A[i+K]
  ans = max(ans,n+m,n)
print(ans)