import Data.List

main = do
  getLine
  as <- map read . words <$> getLine :: IO [Int]
  print $ rect as

rect = calc . group . reverse . sort

calc gs = max (product (map head gs2)) ((head gs4)^2)
  where
    gs2 = headhead1 $ filter (flip elem [2,3] . length) gs
    gs4 = head1 $ filter ((>=4) . length) gs

head1 xs = if null xs then [0] else head xs
headhead1 xs = if length xs < 2 then [[0]] else take 2 xs