from itertools import accumulate as acc
N, K, *A = map(int, open(0).read().split())
B = [0]+list(acc(A))
j = -1
m = 0
k = -1
n = 10**30
for i in range(N-K+1):
  if B[i+K]-B[i]>m:
    m = B[i+K]-B[i]
    j = i
  if B[i+K]-B[i]<n:
    k = i
    n = B[i+K]-B[i]
for i in range(j):
  if A[i]>0:
    m += A[i]
for i in range(j+K,N):
  if A[i]>0:
    m += A[i]
for i in range(k):
  if A[i]<0:
    n += A[i]
for i in range(k+K,N):
  if A[i]<0:
    n += A[i]
n = sum(A)-n
print(max(n,m))