{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import qualified Data.Map as M
-- import qualified Data.Char as C
import qualified Data.List as L
-- import qualified Data.IntSet as I
-- import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
readFloat  = read :: String -> Float
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

solve _ [] = 0
solve [a] xxs@(x:xs) =
  if length (takeWhile (x ==) xxs) >= 2
  then a*x
  else solve [a] xs
solve [ ] xxs@(x:xs) =
  let !howmany = length (takeWhile (x ==) xxs) in
  if howmany >= 4 then x*x
  else if howmany >= 2 then solve [x] (dropWhile (x==) xxs)
  else solve [ ] xs

main :: IO ()
main = do
  n  <- getInt
  as <- getIntList
  print $ solve [] $ L.sortOn (\a -> -a) as
