n,k = gets.chomp.split(" ").map { |e| e.to_i }
a = gets.chomp.split(" ").map { |e| e.to_i }

p (0..n-k).map { |i|
    head = a[0,i].select { |e| e>0 } .inject { |mem, var| mem+var }
    body = [a[i,k].inject { |mem, var| mem+var }, 0].max
    tail = a[i+k,n-k+i].select { |e| e>0 } .inject { |mem, var| mem+var }
    head ||= 0
    tail ||= 0
    head+body+tail
}.max