import Data.List (sortBy,group)
import Control.Arrow ((&&&))

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  as <- map (length&&&head).group.sortBy (flip compare).map read.words <$> getLine :: IO [(Int,Int)]
  let ls = filter ((>1).fst) as
  if length ls > 1
    then print ((snd.head) ls*(snd.head.tail) ls)
    else print 0
