let rec fix ~f x = f (fix ~f) x

let modulo = 1000000007
let ( *@) a b = a * b mod modulo
let rec ( **@) a n = 
  if n = 0 then 1
  else if n mod 2 = 1 then a *@ a **@ (n-1)
  else let h = a **@ (n/2) in h *@ h

let rec factorize x =
  fix 2 x [] ~f:(fun f d y m -> 
    if y = 1 || d * d > x then
      if y > 1 then (y, 1) :: m else m
    else 
      let c, y = fix (0, y) ~f:(fun g (c, y) ->
        if y mod d > 0 then (c, y)
        else g (c+1, y / d))
      in
      f (d+1) y (if c = 0 then m else (d, c) :: m))
  |> List.rev

let lcm x y =
  fix x y [] ~f:(fun f xs ys m ->
    match xs, ys with
    | [], z | z, [] -> List.rev_append z m
    | (dx,cx)::xs as xs0, ((dy,cy)::ys as ys0) -> 
        if dx = dy then f xs ys ((dx, max cx cy) :: m)
        else if dx < dy then f xs ys0 ((dx,cx)::m)
        else f xs0 ys ((dy,cy)::m))
  |> List.rev

let div x y =
  fix x y 1 ~f:(fun f xs ys v ->
    match xs, ys with
    | [], [] -> v
    | [], _ -> raise (Invalid_argument "FOO")
    | (d,c)::xs, [] -> f xs [] (d **@ c *@ v)
    | (dx,cx)::xs, ((dy,cy)::ys as ys0) ->
        if dx = dy then f xs ys (dx **@ (cx - cy) *@ v)
        else f xs ys0 (dx **@ cx *@ v))

let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let fa = Array.map factorize a in
  let m = Array.fold_left lcm [] fa in
  Array.fold_left (fun acc v -> (acc + div m v) mod modulo) 0 fa
  |> Printf.printf "%d\n"
