{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Lazy.Char8 as B

readIntLL :: IO [[Int]]
readIntLL = map(unfoldr(B.readInt.B.dropWhile(==' '))).B.lines<$>B.getContents

rsort = sortBy $ flip compare

ts [] = [0,0]
ts (_:[]) = [0,0]
ts (a:b:as)
    | a == b = a : (ts as)
    | True = ts (b:as)

main=do
    n:as <- readIntLL
    print $ product $ take 2 $ ts $ rsort $ head as
