import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n  <- getInt
    as <- filter (\g -> length g >= 2) . group . sortOn Down <$> getIntList
    let ans | null as = 0
            | length (head as) >= 4 = (head (head as)) ^ 2
            | length as == 1 = 0
            | otherwise = let (a:b:_) = as in head a * head b
    print ans