{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE KindSignatures      #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Strict              #-}
{-# LANGUAGE TypeApplications    #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict    as M
import           Data.List             (mapAccumL, unfoldr)
import           Data.Proxy            (Proxy (..))
import           Data.Ratio            ((%))
import           GHC.TypeLits          (KnownNat, Nat, natVal)

newtype Mod a (n :: Nat) = Mod { unMod :: a }
  deriving (Eq, Ord)

modulo :: forall n a. (Integral a, KnownNat n) => a -> Mod a n
modulo a = Mod . mod a $ modulus @n

modulus :: forall n a. (Integral a, KnownNat n) => a
modulus = fromInteger $ natVal (Proxy @n)

instance Show a => Show (Mod a n) where
  show (Mod a) = show a

instance (Integral a, KnownNat n) => Num (Mod a n) where
  fromInteger = modulo . fromInteger

  Mod a + Mod b = modulo $ a + b
  Mod a * Mod b = modulo $ a * b

  abs    (Mod a) = modulo $ abs a
  signum (Mod a) = modulo $ signum a
  negate (Mod a) = modulo $ negate a

instance (Integral a, KnownNat n) => Enum (Mod a n) where
  succ (Mod x)
    | x == unMod (maxBound :: Mod a n) =
        errorWithoutStackTrace "Prelude.Enum.succ{Mod}: tried to take `succ' of maxBound"
    | otherwise           = Mod $ x + 1

  pred (Mod x)
    | x == unMod (minBound :: Mod a n) =
        errorWithoutStackTrace "Prelude.Enum.pred{Mod}: tried to take `pred' of minBound"
    | otherwise            = Mod $ x - 1

  toEnum = fromIntegral
  fromEnum = fromIntegral . unMod

  enumFrom     x   = enumFromTo     x maxBound
  enumFromThen x y = enumFromThenTo x y bound
    where
      bound | fromEnum y >= fromEnum x = maxBound
            | otherwise                = minBound

instance (Integral a, KnownNat n) => Bounded (Mod a n) where
  maxBound = Mod $ pred (modulus @n)
  minBound = 0

instance (Integral a, KnownNat n) => Real (Mod a n) where
  toRational (Mod a) = toInteger a % 1

instance (Integral a, KnownNat n) => Integral (Mod a n) where
  toInteger (Mod a) = toInteger a
  quotRem a b = (a * inv b, 0)

inv :: forall n a. (Integral a, KnownNat n) => Mod a n -> Mod a n
inv x = go (unMod x) (modulus @n) 1 0
  where go _ 0 u _ = modulo u
        go a b u v = go b (a - t * b) v (u - t * v)
          where t = a `div` b

type MInt = Mod Int 1000000007

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  print $ solve n as

solve :: Int -> [Int] -> MInt
solve _ as = sum $ [l `div` (modulo a :: MInt) | a <- as]
  where l = product [(modulo p :: MInt) ^ f | (p, f) <- M.assocs pfs]
        pfs = M.fromListWith max $ concatMap primeFactorize as

primeFactorize :: Int -> [(Int, Int)]
primeFactorize n
  | p == 1 = pfs'
  | otherwise = (p, 1) : pfs'
  where pfs' = filter (\(_, f) -> f /= 0) pfs
        (p, pfs) = mapAccumL factor n ps
        ps = [2 .. x]
        x = floor $ (sqrt (fromIntegral n) :: Double)

factor :: Int -> Int -> (Int, (Int, Int))
factor n p = go n 0
  where go m f
          | y == 0    = go x $ f + 1
          | otherwise = (m, (p, f))
          where (x, y) = divMod m p

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine



Measured memory_bytes: 7944