import Data.List

main = do
  n <- getLine
  a <- (map read . words) <$> getLine
  putStrLn .show $ solve a

solve:: [Int] -> Int
solve a
  | length s < 2 = 0
  | otherwise = foldl (*) 1 s
  where
    s = take 2 .map head . filter (\x -> length x > 1) . group $ reverse $ sort a
