local n, k = io.read("*n", "*n")
local sum, psum = {}, {}
local cur, pcur = 0, 0
for i = 1, n do
  local a = io.read("*n")
  cur = cur + a
  sum[i] = cur
  if 0 < a then
    pcur = pcur + a
  end
  psum[i] = pcur
end
local mma = math.max
local ret = 0
for i = 1, n - k + 1 do
  local v = sum[i + k - 1]
  if 1 < i then
    v = v - sum[i - 1]
  end
  v = mma(0, v)
  v = v + psum[n] - psum[i + k - 1]
  if 1 < i then
    v = v + psum[i - 1]
  end
  ret = mma(ret, v)
end
print(ret)
