import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (transpose)

main :: IO ()
main = do
  (n : k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ps <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    (pf, sf) = splitAt k ps
    s0 = sum pf
    m = maximum . map snd . drop (pred k) . fix $ (map (flip (,) s0) pf ++) . walk s0 sf
  print . fromRational $ toRational (m + k) / 2

walk :: Int -> [Int] -> [(Int, Int)] -> [(Int, Int)]
walk s (p : ps) ((q, _) : qs) = (p, s') : walk s' ps qs
  where
    s' = s - q + p
walk _ _ _ = []

fix :: (a -> a) -> a
fix f = x
  where
    x = f x

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
