import Data.Functor stride d [] = [] stride d arr = head arr : (stride d $ drop d arr) main = do [n, k] <- map read . words <$> getLine :: IO [Int] costs <- map read . words <$> getLine :: IO [Int] let d = 2 * k + 1 print $ maximum $ map (\a -> sum . stride d . drop a $ costs) [0..(k `div` 2)]