import Data.List

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

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