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