module Main where import Data.List (sort) type Input = [Int] type Output = Int parse :: String -> Input parse = map read . words . (!! 1) . lines solve :: Input -> Output solve a = let mulSum xs = f xs where f (x:y : xs) = x * y + f xs f _ = 0 in mulSum . sort $ a render :: Output -> String render = show main :: IO () main = interact ( render . solve . parse )