Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let z = 1_000_000_007 in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in

    let factor a =
        let result = Array.make 1001 0 in
        let rec loop rest i =
            if rest = 1 then () else
                if rest < i * i then (result.(rest) <- 1) else
                    if rest mod i <> 0 then loop rest (i + 1) else
                        let rec count r v =
                            if r mod i = 0 then count (r / i) (v + 1) else
                                let () = result.(i) <- result.(i) + v in
                                loop r (i + 1)
                        in
                        count rest 0
        in
        loop a 2 ;
        result
    in

    let pow_mod a b =
        let rec loop r i acc =
            if i = 0 then acc else
                let acc = if i land 1 = 1 then acc *@ r else acc in
                loop (r *@ r) (i lsr 1) acc
        in
        loop a b 1
    in
    let reduce a =
        let rec loop i acc =
            if i = 1001 then acc else loop (i + 1) (acc *@ pow_mod i a.(i))
        in
        loop 2 1
    in
    let mul a b = Array.init 1001 (fun i -> a.(i) + b.(i)) in
    let div a b = Array.init 1001 (fun i -> a.(i) - b.(i)) in
    let gcd a b = Array.init 1001 (fun i -> min a.(i) b.(i)) in
    let lcm a b = div (mul a b) (gcd a b) in

    let rec loop i acc =
        if i = n then acc else loop (i + 1) (lcm acc (factor a.(i)))
    in
    let l = loop 1 (factor a.(0)) in
   Array.fold_left (fun acc v -> acc +@ reduce (div l (factor v))) 0 a |> Printf.printf "%d\n"
)