N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
RUI = [0]
ALL = [0]

A.each do |a|
  RUI << RUI.last + [0, a].max
  ALL << ALL.last + a
end

base = RUI.last
ans = 0

K.upto(N) do |i|
  score = base - (RUI[i] - RUI[i - K])

  ans = score if ans < score
end

1.upto(N - K) do |i|
  score = RUI[i] + [0, (ALL[i + K] - ALL[i])].max + (RUI[N] - RUI[i + K])

  ans = score if ans < score
end

puts ans
