import Control.Applicative ((<$>), (<*>)) diff :: Double -> (Double -> Double) diff n x = n * x ** (n - 1) inte :: Double -> (Double -> Double) inte n | n == -1.0 = log | otherwise = \x -> x ** (n+1) / (n+1) main :: IO () main = do getLine b <- readLn :: IO Double as <- map (read :: String -> Double) . words <$> getLine print $ sum $ (map diff as) <*> return b print $ sum $ (map inte as) <*> return b