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

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let ls = concat $ filter (\s -> length s >= 2) $ group $ sortBy (flip compare) as
    print $ area ls
    where
        area [] = 0
        area [_] = 0
        area [_, _] = 0
        area [_, _, _] = 0
        area (a:_:c:d:_)
            | c == d = a * c
            | otherwise = a * d
