import Data.List
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 = filter (\s -> length s >= 2) $ group $ sortBy (flip compare) as
    print $ if length ls < 2 then 0 else head (head ls) * head (ls !! 1)
