import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM
import Data.Ord

type Map = IM.IntMap Int

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

solve :: [(Int, Int)] -> Int
solve [] = 0
solve [(l1, c1)] = if c1 >= 4 then l1 ^ 2 else 0
solve [(l1, c1), (l2, c2)] = l1 * l2

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  let res = take 2 . filter ((>=2) . snd) . sortOn (Down . fst) . IM.toList $ foldl (\m a -> countUp a 1 m) IM.empty as
  print $ solve res