import Data.List
import qualified Data.IntMap.Lazy as IM
 
main = do
  getLine
  as <- map read . words <$> getLine
  print . h . sortBy (flip compare) $ f IM.empty as
 
f :: IM.IntMap Int -> [Int] -> [Int]
f im [] =  [ a | (a, n) <- IM.toList im, n >= 2 ]
f im (y:ys) = f (IM.insertWith g y 1 im) ys
 
g x y = y + 1

h (x:y:zs) = x * y
h _ = 0