module Main where

import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    getLine
    as <- fmap readi . B.words <$> B.getLine :: IO [Int]
    let bs = take 2 . filter ((>= 2) . length)
           . group . sortBy (flip compare) $ as
    let ans = case bs of
            []   -> 0
            [xs] -> 0
            [xs, ys] | length xs >= 4 -> head xs ^ 2
                     | otherwise      -> head xs * head ys
    print ans