n,k = map(int,input().split())
a = list(map(int, input().split()))
al = [0]*(n+1)
pl = [0]*(n+1)
ans = 0
for i in range(n):
  al[i+1] = al[i] + a[i]
  pl[i+1] = pl[i]
  if a[i] > 0: pl[i+1] += a[i]
for r in range(k,n+1):
  l = r-k
  cur = pl[l] + max(0, al[r] - al[l]) + pl[n] - pl[r]
  if ans < cur: ans = cur
print(ans)