import Data.List
import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as

solve :: [Int] -> Int
solve as = --trace (show as') $
           if length as' < 2
              then 0
              else case as' of
                     [a, b, _] -> head a * head b
                     [a, b] -> head a * head b
                     _ -> 0
  where
    as' = filter ((> 1) . length) $
          group $ sortBy (flip compare) as
    
