import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main::IO()
main=do
    _ <- readLn::IO Int
    as <- map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

    let bs = gen (as ++ [0])  M.empty
        cs = M.toDescList $ M.filter ( > 1) bs
        ds = case cs == [] of
                  True -> 0
                  False ->  if snd (cs !! 0) > 3 then fst (cs !! 0) ^ 2
                                                 else fst (cs !! 0) * fst (cs !! 1)
    print $ ds

gen::[Integer] -> M.Map Integer Int -> M.Map Integer Int
gen (a:as) me  
    |null as = me
    |M.notMember a me = gen as (M.insert a 1 me)
    |M.member a me = gen as (M.insert a ((me M.! a) + 1) me)
