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

solve :: [Int] -> Int
solve = getMaxArea

getMaxArea :: [Int] -> Int
getMaxArea s
    | a1 > 0 && a2 > 0 = a1 * a2
    | otherwise = 0
    where
        a = getMaxLength 0 s
        a1 = fst a
        a2 = snd a

getMaxLength :: Int -> [Int] -> (Int, Int)
getMaxLength _ [] = (-1, -1)
getMaxLength y (x1:x2:xs)
    | x1 == x2 && y > 0 = (y, x1)
    | x1 == x2 = getMaxLength x1 xs
    | otherwise = getMaxLength y (x2 : xs)
getMaxLength _ _ = (-1, -1)


main :: IO ()
main = do
    n <- getLine
    a <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine :: IO [Int]
    let s = sortBy (flip compare) a
    print $ solve s