Scanf.scanf "%d" (fun n ->
    let nmax = 1000000 in
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let z = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in

    let minprime =
        let r = Array.init (nmax + 1) (fun a -> a) in
        for i = 2 to int_of_float (sqrt (float nmax)) do
            let rec loop j =
                if j <= nmax then (
                    r.(j) <- min r.(j) i;
                    loop (j + i)
                )
            in
            loop (i * i)
        done;
        r
    in

    let invsum = Array.fold_left (fun acc v -> acc +@ inv v z) 0 a in
    let lcm = Array.make (nmax + 1) 0 in
    Array.iter (fun v ->
        let rec loop v =
            if v > 1 then (
                let q = minprime.(v) in
                let rec count r i =
                    if r mod q = 0 then count (r / q) (i + 1) else (
                        lcm.(q) <- max lcm.(q) i;
                        loop r
                    )
                in
                count v 0
            )
        in
        loop v
    ) a;

    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 =
        let rec loop i acc =
            if i > nmax then acc else loop (i + 1) (acc *@ pow_mod i lcm.(i))
        in
        loop 2 1
    in
    reduce *@ invsum |> Printf.printf "%d\n"
)