import Control.Monad
import Control.Applicative
import Data.List
import Data.Array

strToInt s = (read :: String -> Int)
           
           
main = do

  n <- readLn :: IO Int
  xn <- map read . words <$> getLine
  
  let an = sub $ reverse $ sort xn
  
  if (length an) > 1 then print ( (an !! 0) * (an !! 1) )
                     else print 0


sub :: [Int] -> [Int]
sub [] = []
sub (x:[]) = []
sub (x:xn) = if (x == (head xn))
             then [x] ++ sub (tail xn)
             else sub xn