import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

getMax as k m
  | k > length as = m
  | m' > m = getMax as' k m'
  | otherwise = getMax as' k m
  where
    bs = take k as
    m' = sum bs
    as' = tail as

main = do
  [n, k] <- getIntList
  ps <- getIntList
  print $ (fromIntegral ((getMax ps k 0) + k)) / 2
