main = do
    s <- map read . words <$> getLine :: IO [Int] 
    k <- readLn :: IO Int

    print $ solve s k


solve :: [Int] -> Int-> Int
solve s k
    | k ==0 = (sum s) - (maximum s)
    | otherwise = 2 * (maximum s) + solve s (k -1)
