let rec input n =
		if n = 0
		then []
		else match List.map(fun x -> int_of_string x)(Str.split (Str.regexp " ") (read_line ())) with
		| x::y::xs -> (x,y) :: input (n-1)
		| x::xs -> (x,1) :: input (n-1)
		| [] -> (1,1) :: input n

let solve lst =
	let rec solve_loop before lst = match lst with
		| [] -> let(a,b) = before in a + b
		| first :: xs ->
			let (x,y) = first in
			let (a,b) = before in
			let ratio = max ((a-1)/x+1) ((b-1)/y+1) in
				solve_loop (x*ratio,y*ratio) xs
	in
		solve_loop (1,1) lst
	
let main =
	print_string (string_of_int (solve (input (int_of_string (read_line ())))))

let () = main