import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
pa = [0] * N
for i in range(N): pa[i] = a[i] * (a[i] > 0)
csp = [0] * (N + 1)
for i in range(N): csp[i + 1] = csp[i] + pa[i]
#print(csp, cs)
res = 0
for i in range(N - K + 1):
  x = cs[i + K] - cs[i]
  y = csp[-1] - (csp[i + K] - csp[i])
  t = max(0, x) + y
  res = max(res, t)
print(res)