import Control.Applicative
import Control.Monad
import qualified Data.Map as M
import Data.List
main = do
 _ <- getLine
 a_s <- (map negate . map read . words) <$> getLine
 print $ analyze a_s

analyze :: [Integer] -> Integer
analyze input = foo arr
 where arr = take 2 . filter ((>1) . snd) . sort . M.toList $ M.fromListWith (+) [(c, 1) | c <- input]

foo [] = 0
foo [(x,u)]
 | u >= 4 = x*x
foo [(x,u),(y,_)]
 | u < 4 = x*y
 | otherwise = x*x
 

