from itertools import accumulate

n,k = map(int, input().split())
a = list(map(int, input().split()))
b = [max(0,i) for i in a]
cumsum_a = [0] + list(accumulate(a))
cumsum_b = [0] + list(accumulate(b))
ans = 0
for i in range(n-k+1):
  tmp = max(0,cumsum_a[i+k]-cumsum_a[i]) + cumsum_b[i] + cumsum_b[n] - cumsum_b[i+k]
  ans = max(ans,tmp)
print(ans)