Scanf.scanf "%d" (fun k ->
    let a = Array.init k (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let rec loop i acc1 acc2 =
        if i < 0 then acc1, acc2 else
            let v = a.(i) in
            let c2 = acc2 / v in
                if c2 * v < acc1 then (-1, -1) else
                    let c1 = ((acc1 + v - 1) / v) * v in
                    loop (i - 1) c1 (c2 * v + v - 1)
    in
    let acc1, acc2 = loop (k - 1) 2 2 in
    if acc1 < 0 then Printf.printf "-1\n" else
                     Printf.printf "%d %d\n" acc1 acc2
)