Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
from fractions import gcd
from functools import reduce
MOD = 10**9 + 7
def lcm(a, b):
    g = gcd(a,b)
    return a*b//g
def lcm_list(numbers):
    return reduce(lcm, numbers)

N = int(input())
A = inpl()
K = lcm_list(A)
ans = 0
for i in range(N):
    ans += K // A[i]
    ans %= MOD
print(ans)


Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
from fractions import gcd
from functools import reduce
MOD = 10**9 + 7
import math
class Factorizer:
    def __init__(self):
        self.primes_ceil = 5
        self.primes = [2,3]

    def find_primes(self, primes_ceil):
        if primes_ceil <= self.primes_ceil:
            return self.primes

        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        r, m = prev_primes_ceil//6, prev_primes_ceil%6
        if m <= 1:
            i = r*6 + 1
            mod_flag = True
        else:
            i = r*6 + 5
            mod_flag = False

        while i < self.primes_ceil:
            sieve = True
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = False
                    break
            if sieve:
                self.primes.append(i)
            if mod_flag:
                i += 4
                mod_flag = False
            else:
                i += 2
                mod_flag = True

        return self.primes

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(math.sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

def primes(N):
    P = []
    for i in range(2,N):
        sieve = 1
        for p in P:
            if p*p > i:
                break
            elif i % p == 0:
                sieve = 0
                break
        if sieve == 0:
            continue
        else:
            P.append(i)
    return P

def inv_mod(a, p=MOD):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

def lcm(a, b):
    g = gcd(a,b)
    return a*b//g

def lcm_list(numbers):
    return reduce(lcm, numbers)

N = int(input())
A = inpl()
M = max(A)
fct = Factorizer()
P = fct.find_primes(M+1)
L = len(P)
pn = dict()
for i in range(L):
    pn[P[i]] = i
factors = [0] * L
for i in range(N):
    f, p = fct(A[i])
    for k in range(len(f)):
        m = pn[f[k]]
        factors[m] = max(factors[m], p[k])
K = 1
for l in range(L):
    K *= pow(P[l],factors[l],MOD)
    K %= MOD
ans = 0
for i in range(N):
    ans += K * inv_mod(A[i])
    ans %= MOD
print(ans)