n,h = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
s = []
len = n
ans = 0
sum = 0
(n).times do|i|
    sum+= a[i] if a[i] > 0
end
poet = 0
h.times do |d|
  sum -= a[d] if(a[d] > 0)
  poet += a[d]
end
str = 0
en = (h-1) 
max = poet
min = poet
(n-h).times do |u|
  poet += a[h+u]
  poet -= a[u]
  sum += a[u] if(a[u] > 0)
  sum -= a[h+u] if(a[h+u] > 0)
  ans = sum
  ans += poet if poet > 0
  if(ans > max)
  max = ans
  end 
end

if (ans < 0)
  puts 0
  exit
end
puts  max