import           Control.Monad
import           Data.Array.Unboxed
import           Data.List.Split
import           Data.List

main :: IO ()
main = do
  n  <- readLn
  ta <- replicateM n $ map read . words <$> getLine

  let s = solve (1, 1) ta

  print $ uncurry (+) s

solve :: (Int, Int) -> [[Int]] -> (Int, Int)
solve vt [] = vt
solve (avt, bvt) (rt : rts) | newA >= avt = solve ((b `div` brt) * art, b) rts
                            | otherwise   = solve (a, (a `div` art) * brt) rts
 where
  art  = head rt
  brt  = last rt
  a    = getMinVt avt art
  b    = getMinVt bvt brt
  newA = (b `div` brt) * art
  getMinVt :: Int -> Int -> Int
  getMinVt vt rt | vt `mod` rt == 0 = vt
                 | otherwise        = vt + (rt - (vt `mod` rt))
