import qualified Data.Map as M

main = do
  getLine
  as <- map read . words <$> getLine
  print . h . M.toDescList $ f M.empty as

f m [] = M.filter (> 0) $ M.map g m
f m (a:as) = M.insertWith (const succ) a 1 (f m as)

g a
  | a >= 4 = 2
  | a >= 2 = 1
  | otherwise = 0

h ((k, v):(k', _):_)
  | v == 2 = k * k
  | otherwise = k * k'
h _ = 0
