N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

p = [0] * N
q = [0] * N

p[0] = a[0] if a[0] > 0 else 0
q[0] = a[0]

for i in range(1, N):
  p[i] = p[i - 1] + (a[i] if a[i] > 0 else 0)
  q[i] = q[i - 1] + a[i]

ans = 0
for i in range(N - K + 1):
  t = i + K - 1
  x = p[-1] - p[t] + (p[i - 1] if i != 0 else 0)
  ans = max(ans, x)
  x += q[t] - (q[i - 1] if i != 0 else 0)
  ans = max(ans, x)

print(ans)
