{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE MultiWayIf #-}
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict    as M
import           Data.Maybe            (fromJust, fromMaybe)

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BS.words <$> BS.getLine
  print . fromMaybe 0 $ solve n as

solve :: Int -> [Int] -> Maybe Int
solve n as = do
  let m = filter (\(_, v) -> v >= 2) . M.toDescList $ M.fromListWith (+) [(a, 1) | a <- as]
  (x, m') <- findBar m
  (y, _)  <- findBar m'
  return $ x * y

findBar :: [(Int, Int)] -> Maybe (Int, [(Int, Int)])
findBar m = do
  (k, v) <- if null m then Nothing else Just $ head m
  if
    | v >= 4 -> Just (k, m)
    | v >= 2 -> Just (k , tail m)
    | otherwise -> Nothing


readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt
