{-# LANGUAGE ViewPatterns #-}

import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let ls = V.take 2 $ V.unfoldr f $ V.fromList $ sortBy (flip compare) (0 : as)
    print $ if V.length ls == 2 then V.product ls else 0
    where
        v4 vs =
            if V.length vs < 3
                then Nothing
                else
                    let x = vs V.! 0
                        y = vs V.! 1
                    in Just (x, y, V.unsafeDrop 2 vs)
        f (v4 -> Nothing) = Nothing
        f (v4 -> Just(x, y, xs))
            | x == y    = Just (x, xs)
            | otherwise = f (y `V.cons` xs)
        f _ = Nothing
