import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map as MP
import Data.Char

make :: VU.Vector Int -> MP.Map Int Int
make vec = VU.foldl' step MP.empty vec
    where
        step :: MP.Map Int Int -> Int -> MP.Map Int Int
        step m v = 
            case MP.lookup v m of
                Just _ -> MP.adjust (+1) v m
                Nothing -> MP.insert v 1 m 

solve :: MP.Map Int Int -> Int -> Int
solve m acc
    | MP.null m = 0
    | v >= 4 && acc == 0 = k * k
    | v >= 2 && acc /= 0 = k * acc
    | v >= 2 && acc == 0 = solve m' k
    | otherwise = solve m' acc
        where
            ((k,v), m') = MP.deleteFindMax m

main = do
    n <- readLn :: IO Int 
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve (make xs) 0