import Control.Applicative
import Data.List
import Data.Array

main = do
  [n,k] <- map read . words <$> getLine :: IO [Integer]
  as <- map read . words <$> getLine :: IO [Integer]

  let
    xs = listArray (0,n) $ scanl (+) 0 as
    ys = listArray (0,n) $ scanl (+) 0 (map (max 0) as)
    s =  sum (map (max 0) as)

  
  print $ maximum $ map (\i -> (max (xs!(i+k-1) - xs!(i-1)) 0) + s - (ys!(i+k-1) - ys!(i-1))) [1..n-k+1]

  
