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