Given are N positive integers A_1,...,A_N.
Consider positive integers B_1, ..., B_N that satisfy the following condition.
Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.
Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.
Since the answer can be enormous, print the sum modulo (10^9 +7).

-----Constraints-----
 - 1 \leq N \leq 10^4
 - 1 \leq A_i \leq 10^6
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 ... A_N

-----Output-----
Print the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).

-----Sample Input-----
3
2 3 4

-----Sample Output-----
13

Let B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.

Difficulty: MEDIUM

Solutions:
from math import gcd
from functools import reduce

def resolve():

	def lcm_base(x, y):
		return x * y // gcd(x, y)

	def lcm_list(arr):
		return reduce(lcm_base, arr, 1)
	MOD = 10 ** 9 + 7
	N = int(input())
	A = list(map(int, input().split()))
	num = lcm_list(A) % MOD
	ans = 0
	for a in A:
		ans += num * pow(a, MOD - 2, MOD) % MOD
	ans %= MOD
	print(ans)

def __starting_point():
	resolve()
__starting_point()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
n = int(input())
a = [int(i) for i in input().split()]
tmp = 1
for i in a:
	tmp = lcm(i, tmp)
mod = 1000000007
print(sum((tmp // i for i in a)) % mod)


from math import gcd
N = int(input())
A = list(map(int, input().split()))

def lcm(a, b):
	return a * b // gcd(a, b)
lcm_a = 1
for i in A:
	lcm_a = lcm(lcm_a, i)
ans = 0
for i in A:
	ans += lcm_a // i
print(ans % (10 ** 9 + 7))


n = int(input())
nums = list(map(int, input().split()))
import math
summ = 1
b = 1
mod = 10 ** 9 + 7
for idx in range(1, n):
	temp = b * nums[idx - 1]
	gcd = math.gcd(temp, nums[idx])
	multiple = nums[idx] // gcd
	summ *= multiple
	b = b * nums[idx - 1] * multiple // nums[idx]
	summ += b
	summ %= mod
print(summ)


n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
	return gcd(b, a % b) if b else a

def lcm(a, b):
	return a * b // gcd(a, b)
k = 1
for i in a:
	k = lcm(k, i)
ans = 0
for i in a:
	ans += k // i
ans %= 10 ** 9 + 7
print(ans)


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)
n = int(input())
a = list(map(int, input().split()))
l = lcm(*a)
MOD = 10 ** 9 + 7
ans = 0
for i in range(n):
	ans += l // a[i]
print(ans % MOD)


import math
n = int(input())
a = list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
p = 1000000007
k = 1
for i in range(n):
	k = lcm(k, a[i])
k %= p
ans = 0
for i in range(n):
	ans += k * pow(a[i], p - 2, p)
	ans %= p
print(ans)


import numpy as np

class SieveOfEratosthenes:

	def __init__(self, V):
		self.is_prime = np.ones(V + 1, dtype=bool)
		self.is_prime[4::2] = False
		self.is_prime[9::3] = False
		self.is_prime[25::5] = False
		self.primes = [2, 3, 5]
		for i in range(7, V + 1, 2):
			if self.is_prime[i]:
				self.primes.append(i)
				self.is_prime[i * i::i] = False

	def factorize(self, x):
		assert x >= 1
		if x == 1:
			return [(1, 1)]
		result = []
		for p in self.primes:
			exp = 0
			while x % p == 0:
				exp += 1
				x = x // p
			if exp > 0:
				result.append((p, exp))
			if p * p > x:
				break
		if x > 1:
			result.append((x, 1))
		return result
N = int(input())
M = 10 ** 9 + 7
A = list(map(int, input().split()))
sieve = SieveOfEratosthenes(10 ** 3)
F = [dict(sieve.factorize(a)) for a in A]
lcm = F[0]
for i in range(1, len(F)):
	for (p, e) in list(F[i].items()):
		if p in lcm:
			lcm[p] = max(lcm[p], e)
		else:
			lcm[p] = e
val = 1
for (p, e) in list(lcm.items()):
	val = val * pow(p, e, M) % M
B = [val * pow(a, M - 2, M) % M for a in A]
print(sum(B) % M)


N = input()
A = [int(x) for x in input().split()]

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a // gcd(a, b) * b
L = 1
for a in A:
	L = lcm(L, a)
print(sum((L // a for a in A)) % (10 ** 9 + 7))


import sys
import math
import fractions
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
mod = 10 ** 9 + 7

def factorize(n):
	b = 2
	fct = defaultdict(lambda : 0)
	while b * b <= n:
		while n % b == 0:
			n //= b
			fct[b] += 1
		b = b + 1
	if n > 1:
		fct[n] += 1
	return fct

def divmod(x, mod=10 ** 9 + 7):
	return pow(x, mod - 2, mod)

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	B = [[1] for _ in range(N)]
	fac_list = defaultdict(lambda : 0)
	for i in range(N):
		d = factorize(A[i])
		for (k, v) in list(d.items()):
			fac_list[k] = max(fac_list[k], v)
	lcm = 1
	for (k, v) in list(fac_list.items()):
		lcm *= k ** v
		lcm %= mod
	ans = 0
	for i in range(N):
		ans += divmod(A[i])
		ans %= mod
	ans *= lcm
	ans %= mod
	print(ans)

def __starting_point():
	solve()
__starting_point()


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
mod = 10 ** 9 + 7

class Factorize(object):

	def __init__(self, maxnum):
		self.primes = self.__smallest_prime_factors(maxnum)

	def factorize_list(self, n):
		fct = []
		while n != 1:
			fct.append(self.primes[n])
			n //= self.primes[n]
		return fct

	def factorize_dict(self, n):
		fct = defaultdict(lambda : 0)
		while n != 1:
			fct[self.primes[n]] += 1
			n //= self.primes[n]
		return fct

	def __smallest_prime_factors(self, n):
		prime = list(range(n + 1))
		for i in range(2, int(n ** 0.5) + 1):
			if prime[i] != i:
				continue
			for j in range(i * 2, n + 1, i):
				prime[j] = min(prime[j], i)
		return prime

def divmod(x, mod=10 ** 9 + 7):
	return pow(x, mod - 2, mod)

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	fct = Factorize(max(A))
	lcm_dict = defaultdict(lambda : 0)
	for i in range(N):
		d = fct.factorize_dict(A[i])
		for (k, v) in list(d.items()):
			lcm_dict[k] = max(lcm_dict[k], v)
	lcm = 1
	for (k, v) in list(lcm_dict.items()):
		lcm *= k ** v
		lcm %= mod
	ans = 0
	for i in range(N):
		ans += divmod(A[i])
		ans %= mod
	ans *= lcm
	ans %= mod
	print(ans)

def __starting_point():
	solve()
__starting_point()


n = int(input())
l = list(map(int, input().split(' ')))

def gcd(a, b):
	return b if a % b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
hoge = 1
for p in l:
	hoge = lcm(hoge, p)
ans = 0
for p in l:
	ans += hoge // p
print(ans % int(1000000000.0 + 7))


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
a = max(A)
prime_num = [2]
sgn = [0 for _ in range(max(int(a ** 0.5) + 1, 4))]
sgn[2] = 1
for k in range(3, len(sgn), 2):
	if sgn[k] == 0:
		prime_num.append(k)
		for j in range(k, a + 1, k ** 2):
			sgn[k] = 1
baisu = []
count = [0 for _ in range(a + 1)]
for k in range(N):
	b = 0 + A[k]
	for p in prime_num:
		if p ** 2 <= b:
			if b % p == 0:
				if count[p] == 0:
					baisu.append(p)
				c = 0
				while b % p == 0:
					b //= p
					c += 1
				if c > count[p]:
					count[p] = c
		else:
			break
	if b != 1:
		if count[b] == 0:
			count[b] = 1
			baisu.append(b)
product = 1
for item in baisu:
	product *= pow(item, count[item], mod)
	product %= mod
b = mod - 2
blis = []
c = 0
while b > 0:
	if b & 1 == 1:
		blis.append(c)
	c += 1
	b >>= 1

def modinv(a):
	if a == 1:
		return 1
	else:
		res = 1
		li = []
		for _ in range(c):
			li.append(a % mod)
			a = a * a % mod
		for item in blis:
			res = res * li[item] % mod
		return res
ans = 0
for k in range(N):
	ans += product * modinv(A[k])
	ans %= mod
print(ans)


def main():
	from math import gcd
	import sys
	sys.setrecursionlimit(10 ** 9)
	input = sys.stdin.readline
	mod = 1000000007
	N = int(input())
	A = list(map(int, input().split()))
	lcm = 1
	for i in A:
		lcm = lcm * i // gcd(lcm, i)
	lcm %= mod
	ans = 0
	for i in A:
		ans += lcm * pow(i, mod - 2, mod)
		ans %= mod
	print(ans)
main()


n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

def lcm(X, Y):
	x = X
	y = Y
	if y > x:
		(x, y) = (y, x)
	while x % y != 0:
		(x, y) = (y, x % y)
	return X * Y // y
a = 1
c = 0
s = 0
for i in range(n):
	q = lcm(a, A[i])
	s *= q // a
	a = q
	s += q // A[i]
print(s % mod)


from collections import defaultdict
MOD = 10 ** 9 + 7
n = int(input())
alst = list(map(int, input().split()))
dd = defaultdict(int)
ans = 0
for a in alst:
	ans += pow(a, MOD - 2, MOD)
	ans %= MOD
	num = a
	for i in range(2, int(a ** 0.5) + 1):
		cnt = 0
		while num % i == 0:
			num //= i
			cnt += 1
		if cnt > 0:
			dd[i] = max(dd[i], cnt)
	if num != 1:
		dd[num] = max(dd[num], 1)
for (key, value) in list(dd.items()):
	ans *= pow(key, value, MOD)
	ans %= MOD
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
lcm = a[0]
for i in range(1, n):
	lcm = lcm * a[i] // math.gcd(lcm, a[i])
for i in range(n):
	ans += lcm // a[i]
print(ans % mod)


from fractions import *
(n, *a) = map(int, open(0).read().split())
mod = 10 ** 9 + 7
b = a[0]
for i in a:
	b = b * i // gcd(b, i)
print(sum((b // i for i in a)) % mod)


import math
from functools import reduce
from collections import defaultdict

def primeFactor(n):
	res = defaultdict(lambda : 0)
	for i in range(2, int(n ** 0.5) + 1):
		while n % i == 0:
			res[i] += 1
			n = n // i
	if n != 1:
		res[n] += 1
	return res
N = int(input())
A = list(map(int, input().split()))

def gcd(*numbers):
	return reduce(math.gcd, numbers)
MOD = 10 ** 9 + 7
GCD = gcd(*A)
P = defaultdict(lambda : 0)
for i in range(N):
	factors = primeFactor(A[i])
	for (k, v) in list(factors.items()):
		if v > P[k]:
			P[k] = v
P_mod = 1
for k in list(P.keys()):
	P_mod = P_mod * k ** P[k] % MOD
ans = 0
for i in range(N):
	b = A[i]
	mod_inv = pow(b, MOD - 2, MOD)
	ans = (ans + P_mod * mod_inv) % MOD
print(ans)


N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = 1
for a in A:
	t = a * t // gcd(a, t)
ans = 0
for a in A:
	ans += t // a
print(ans % mod)


from itertools import groupby

def fast_prime_factorization_many(lst):
	from subprocess import Popen, PIPE
	res = Popen(['factor'] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b'\n')[:-1]
	return [list(map(int, r.split()[1:])) for r in res]

def main():
	N = int(input())
	A = list(map(int, input().split()))
	mod = 10 ** 9 + 7
	max_factor = [0] * 1010101
	lcm = 1
	Factors = fast_prime_factorization_many(A)
	for factors in Factors:
		for (prime, group) in groupby(factors):
			n = len(list(group))
			n_old = max_factor[prime]
			if n_old < n:
				for i in range(n - n_old):
					lcm = lcm * prime % mod
				max_factor[prime] = n
	ans = 0
	for a in A:
		ans += pow(a, mod - 2, mod)
	ans = ans * lcm % mod
	print(ans)
main()


def gcd(m, n):
	r = m % n
	return gcd(n, r) if r else n

def lcm(m, n):
	return m // gcd(m, n) * n
MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for x in a[1:]:
	l = lcm(x, l)
l %= MOD
ans = 0
for x in a:
	ans += l * pow(x, MOD - 2, MOD) % MOD
print(ans % MOD)


from fractions import *
(_, a) = open(0)
(*a,) = map(int, a.split())
s = 1
for t in a:
	s *= t // gcd(s, t)
print(sum((s // i for i in a)) % (10 ** 9 + 7))


n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
lcm = {}
ps = []
for i in range(n):
	ai = a[i]
	p = 2
	ps.append({})
	while p * p <= ai:
		if ai % p == 0:
			ps[i][p] = 0
			while ai % p == 0:
				ps[i][p] += 1
				ai //= p
			lcm[p] = max(lcm.get(p, 0), ps[i][p])
		p += 1
	if ai > 1:
		ps[i][ai] = 1
		lcm[ai] = max(lcm.get(ai, 0), ps[i][ai])
lcmv = 1
for p in lcm:
	lcmv = lcmv * p ** lcm[p] % mod

def inv(p, k):
	k = mod - k - 1
	ret = 1
	b = p
	while k > 0:
		if k % 2 == 1:
			ret = ret * b % mod
		b = b * b % mod
		k //= 2
	return ret
ret = 0
for i in range(n):
	prod = lcmv
	for p in ps[i]:
		prod = prod * inv(p, ps[i][p]) % mod
	ret = (ret + prod) % mod
print(ret)


import sys
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
DIV = 10 ** 9 + 7
import math
from functools import reduce

def lcm(a, b):
	return a // math.gcd(a, b) * b
G = reduce(lcm, A)
ans = sum(map(lambda x: G // x, A))
print(ans % DIV)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
from math import gcd
ans = a[0]
for i in range(1, n):
	ans = ans * a[i] // gcd(ans, a[i])
s = sum((pow(x, mod - 2, mod) for x in a))
print(s * ans % mod)


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def prime_factorization(n):
	res = []
	for i in range(2, int(pow(n, 0.5)) + 1):
		if n % i == 0:
			ex = 0
			while n % i == 0:
				ex += 1
				n //= i
			res.append([i, ex])
	if n != 1:
		res.append([n, 1])
	return res

def resolve():
	n = int(input())
	A = list(map(int, input().split()))
	prime = [0] * max(A)
	for a in A:
		primes = prime_factorization(a)
		for (num, ex) in primes:
			prime[num - 1] = max(prime[num - 1], ex)
	L = 1
	for i in range(len(prime)):
		if prime[i] == 0:
			continue
		L *= pow(i + 1, prime[i])
	res = 0
	for a in A:
		res += L * pow(a, mod - 2, mod)
		res %= mod
	print(res)

def __starting_point():
	resolve()
__starting_point()


import math

def main():
	MOD = 10 ** 9 + 7
	N = int(input())
	A = list(map(int, input().split(' ')))
	L = 1
	for a in A:
		L = L * a // math.gcd(L, a)
	ans = 0
	for a in A:
		ans += L * pow(a, MOD - 2, MOD)
		ans %= MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b // gcd(a, b)
n = int(input())
numbers = list(map(int, input().split()))
l = numbers[0]
for i in range(1, n):
	l = lcm(l, numbers[i])
ans = 0
for i in range(n):
	ans += l // numbers[i]
MOD = 1000000007
print(ans % MOD)


import math
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 1
lcm = A[0]
for i in range(1, N):
	a = A[i]
	b = lcm
	gcd = math.gcd(a, b)
	lcm = a * b // gcd
	ans *= lcm // b
	ans += lcm // a
	ans %= mod
print(ans)


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
N = int(input())
A = list(map(int, input().split()))
ans = 0
lcm = lcm_list(A)
for i in range(N):
	ans += lcm // A[i]
print(ans % 1000000007)


import sys
import math
import collections
import bisect
import itertools
import fractions
import copy
import decimal
import queue
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline())
ns = lambda : list(map(int, sys.stdin.readline().split()))
na = lambda : list(map(int, sys.stdin.readline().split()))

def main():
	from functools import reduce
	n = ni()
	a = na()
	lcm = a[0]
	for i in a:
		lcm = lcm // math.gcd(lcm, i) * i
	lcm %= MOD
	ans = 0
	for ai in a:
		ans += lcm * pow(ai, MOD - 2, MOD) % MOD
		ans %= MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
from math import gcd
cm = 1
for i in range(n):
	cm = cm * a[i] // gcd(cm, a[i])
ai = sum((pow(x, mod - 2, mod) for x in a))
print(int(ai * cm % mod))


import math
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

def lcm(a, b):
	return a * b // math.gcd(a, b)
l = a[0]
for i in range(n):
	l = lcm(l, a[i])
l %= mod
ans = 0
for i in range(n):
	inv = pow(a[i], mod - 2, mod)
	ans += l * inv % mod
print(ans % mod)


n = int(input())
a = [int(j) for j in input().split()]
t = 1
mod = 10 ** 9 + 7

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
for i in a:
	t *= i // gcd(t, i)
print(sum((t // i for i in a)) % mod)


def main():
	import copy
	n = int(input())
	a = list(map(int, input().split()))
	A = copy.deepcopy(a)
	mod = 10 ** 9 + 7
	l = {}
	for i in range(n):
		for j in range(2, int(a[i] ** 0.5) + 1):
			if a[i] % j == 0:
				cnt = 0
				while a[i] % j == 0:
					cnt += 1
					a[i] = a[i] // j
				if l.get(j) == None:
					l[j] = cnt
				else:
					l[j] = max(cnt, l[j])
		if a[i] != 1:
			if l.get(a[i]) == None:
				l[a[i]] = 1
	L = 1
	for k in list(l.keys()):
		L *= pow(k, l[k], mod)
	L = L % mod
	ans = 0
	for i in range(n):
		ans += L * pow(A[i], mod - 2, mod) % mod
		ans = ans % mod
	print(ans)

def __starting_point():
	main()
__starting_point()


from fractions import *
from functools import *
M = 10 ** 9 + 7
(_, a) = open(0)
(*a,) = map(int, a.split())
s = reduce(lambda x, y: x // gcd(x, y) * y, a) % M
c = 0
for i in a:
	c += s * pow(i, M - 2, M)
	c %= M
print(c)


n = int(input())
nums = list(map(int, input().split()))

def factorize(n):
	if n == 1:
		raise 'n >= 2'
	factor = {}
	div = 2
	while True:
		if div * div > n:
			factor[n] = factor.get(n, 0) + 1
			return factor
		if n % div == 0:
			n //= div
			factor[div] = factor.get(div, 0) + 1
		else:
			div += 1

def factor_product(a, b):
	product = a.copy()
	for (k, v) in list(b.items()):
		product[k] = product.get(k, 0) + v
	return product
import math
summ = 1
b = 1
mod = 10 ** 9 + 7
for idx in range(1, n):
	temp = b * nums[idx - 1]
	gcd = math.gcd(temp, nums[idx])
	multiple = nums[idx] // gcd
	summ *= multiple
	b = b * nums[idx - 1] * multiple // nums[idx]
	summ += b
	summ %= mod
print(summ)


def gcd(a, b):
	return gcd(b, a % b) if b else a
n = int(input())
a = list(map(int, input().split()))
lcm = 1
for v in a:
	lcm *= v // gcd(v, lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans % 1000000007)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * (b // gcd(a, b))
mod = int(1000000000.0 + 7)

def ext_gcd(a, b, x, y):
	if b == 0:
		x[0] = 1
		y[0] = 0
		return a
	g = ext_gcd(b, a % b, y, x)
	y[0] -= a // b * x[0]
	return g

def mod_inv(a):
	x = [0]
	y = [0]
	ext_gcd(a, mod, x, y)
	return (x[0] % mod + mod) % mod
n = int(input())
vs = list(map(int, input().split()))
l = 1
for x in vs:
	l = lcm(l, x)
l = l % mod
ans = 0
for x in vs:
	ans = (ans + l * mod_inv(x) % mod) % mod
print(ans)


n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

def lcm(X, Y):
	x = X
	y = Y
	if y > x:
		(x, y) = (y, x)
	while x % y != 0:
		(x, y) = (y, x % y)
	return X * Y // y
cnt = 0
ans = 0
LCM = 1
for i in range(n):
	Q = lcm(LCM, A[i])
	cnt *= Q // LCM
	LCM = Q
	cnt += Q // A[i]
print(cnt % mod)


import math
import queue
import bisect
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
ipt = stdin.readline
setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]
alp = 'abcdefghijklmnopqrstuvwxyz'

def rev(n, mod=10 ** 9 + 7):
	ni = n
	nm = 1
	m2 = mod - 2
	while m2 > 0:
		if m2 & 1:
			nm = nm * ni % mod
		m2 >>= 1
		ni = ni ** 2 % mod
	return nm

def factorization(n):
	d = dict()
	ni = n
	pn = 2
	t = 0
	while pn ** 2 <= n and ni > 1:
		if ni % pn == 0:
			t += 1
			ni //= pn
		else:
			if not t == 0:
				d[pn] = t
				t = 0
			if pn == 2:
				pn = 3
			else:
				pn += 2
	if t > 0:
		d[pn] = t
	if ni > 1:
		d[ni] = 1
	return d

def main():
	n = int(ipt())
	ans = 0
	a = [int(i) for i in ipt().split()]
	d = defaultdict(int)
	for i in a:
		ans += rev(i)
		di = factorization(i)
		for (ki, vi) in list(di.items()):
			d[ki] = max(d[ki], vi)
		ans %= mod
	for (ki, vi) in list(d.items()):
		ans *= pow(ki, vi, mod)
		ans %= mod
	print(ans)
	return None

def __starting_point():
	main()
__starting_point()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
mod = 1000000007
s = [int(i) for i in input().split()]
ans = 1
for i in s:
	ans *= i // gcd(ans, i)
print(sum((ans // i for i in s)) % mod)


import math
MOD = 10 ** 9 + 7
ans = 0
N = int(input())
A = list(map(int, input().split()))
min_lcm = A[0]
for i in range(1, N):
	min_lcm = A[i] * min_lcm // math.gcd(A[i], min_lcm)
for i in range(N):
	ans += min_lcm // A[i]
print(ans % MOD)


import sys
from functools import reduce
from collections import defaultdict

def input():
	return sys.stdin.readline().rstrip()
mod = 10 ** 9 + 7

def prime(x):
	pf = defaultdict(int)
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			pf[i] += 1
			x //= i
	if x > 1:
		pf[x] = 1
	return pf

def lcm(x, y):
	xx = x.copy()
	yy = y.copy()
	for (k, v) in yy.items():
		xx[k] = max(xx[k], v)
	return xx

def main():
	n = int(input())
	a = list(map(int, input().split()))
	a2 = list(map(prime, a))
	lcms = reduce(lcm, a2)
	lcmss = 1
	for (k, v) in lcms.items():
		lcmss = lcmss * k ** v % mod
	ans = 0
	for aa in a:
		ans += lcmss * pow(aa, -1, mod)
	print(ans % mod)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = [int(x) for x in input().rstrip().split()]
now = 1
mod = 10 ** 9 + 7

def lcm(a, b):
	ori_a = a
	ori_b = b
	while b != 0:
		(a, b) = (b, a % b)
	return ori_a * ori_b // a
for i in a:
	now = lcm(i, now)
print(sum([now // i for i in a]) % mod)


def gcd(a: int, b: int):
	if a > b:
		c = a
		a = b
		b = c
	if a == 0:
		return b
	return gcd(b % a, a)

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

def lcm_of_all(v):
	tmp = v[0]
	for i in range(1, len(v)):
		tmp = lcm(tmp, v[i])
	return tmp
N = int(input())
liA = list(map(int, input().split()))
liB = [-1 for _ in range(N)]
G = lcm_of_all(liA)
MOD = 10 ** 9 + 7
ss = 0
for i in range(N):
	liB[i] = G // liA[i]
	ss += liB[i]
ss %= MOD
print(ss)


import sys, math, collections, itertools
input = sys.stdin.readline
m = 10 ** 9 + 7

def factorization(n):
	arr = []
	temp = n
	i = 2
	if temp % i == 0:
		cnt = 0
		while temp % i == 0:
			cnt += 1
			temp //= i
		arr.append([i, cnt])
	for i in range(3, int(-(-n ** 0.5 // 1)) + 1, 2):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
N = int(input())
A = list(map(int, input().split()))
d = collections.defaultdict(int)
for a in A:
	arr = factorization(a)
	for ar in arr:
		if d[ar[0]] < ar[1]:
			d[ar[0]] = ar[1]
lcm = 1
for (key, val) in list(d.items()):
	lcm = lcm * pow(key, val)
ans = 0
for a in A:
	ans = ans + lcm // a
print(ans % m)


(n, *aa) = map(int, open(0).read().split())
MOD = 10 ** 9 + 7
from collections import defaultdict
from math import sqrt, ceil

def factors(x):
	d = defaultdict(int)
	while x % 2 == 0:
		d[2] += 1
		x //= 2
	for i in range(3, ceil(sqrt(x)) + 2, 2):
		while x % i == 0:
			d[i] += 1
			x //= i
	if x > 1:
		d[x] += 1
	return d
factors_of_aa = list(map(factors, aa))
factors_of_lcm = defaultdict(int)
for factors_of_a in factors_of_aa:
	for k in factors_of_a:
		factors_of_lcm[k] = max(factors_of_lcm[k], factors_of_a[k])
lcm = 1
for (factor, cnt) in factors_of_lcm.items():
	lcm *= pow(factor, cnt, MOD)
ans = 0
for factors_of_a in factors_of_aa:
	to_add = lcm
	for (factor, cnt) in factors_of_a.items():
		to_add *= pow(factor, -cnt, MOD)
		to_add %= MOD
	ans += to_add
	ans %= MOD
print(ans)


from fractions import *
from functools import *
(n, *a) = map(int, open(0).read().split())
l = reduce(lambda a, b: a * b // gcd(a, b), a)
print(sum((l // i for i in a)) % (10 ** 9 + 7))


M = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))

def f(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(l, r) = (a[0], 1)
for i in range(1, n):
	g = f(l, a[i])
	(s, t) = (l // g, a[i] // g)
	(l, r) = (s * t * g, (r * t + s) % M)
print(r)


from math import gcd
mod = 1000000007
n = int(input())
a = list(map(int, input().split()))
d = 1
res = 0
for v in a:
	d *= v // gcd(v, d)
for v in a:
	res += d // v
print(res % mod)


N = int(input())
(*A,) = list(map(int, input().split()))
mod = 10 ** 9 + 7
MAX = 1000000

def gen_primes(n):
	n = int(n ** 0.5) + 2
	is_prime = [True] * n
	is_prime[0] = is_prime[1] = False
	for i in range(2, n):
		if is_prime[i]:
			for j in range(2 * i, n, i):
				is_prime[j] = False
	return [i for (i, flag) in enumerate(is_prime) if flag]
C = [0] * (MAX + 1)
primes = gen_primes(MAX)

def prime_fact(n):
	cnt = 0
	for p in primes:
		if n % p:
			continue
		while n % p == 0:
			cnt += 1
			n //= p
		C[p] = max(C[p], cnt)
		cnt = 0
	if n != 1:
		C[n] = 1
for a in A:
	prime_fact(a)
lcm = 1
for (i, c) in enumerate(C):
	if c:
		lcm = lcm * pow(i, c, mod) % mod
ans = 0
for a in A:
	ans = (ans + lcm * pow(a, mod - 2, mod) % mod) % mod
print(ans)


from math import gcd
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm = 1
for a in A:
	lcm = lcm * a // gcd(lcm, a)
ans = 0
for a in A:
	ans += lcm // a
print(ans % MOD)


import sys
from math import gcd
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

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

def resolve():
	n = int(input())
	A = list(map(int, input().split()))
	L = 1
	for a in A:
		L = lcm(L, a)
	res = 0
	for a in A:
		res += L * pow(a, mod - 2, mod)
		res %= mod
	print(res)

def __starting_point():
	resolve()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
mod = pow(10, 9) + 7
ok = 1
import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
LCM = lcm_list(A)
import numpy as np
B = np.array(A)
C = LCM // B
print(sum(C) % mod)


import math
import sys

def lcm(a, b):
	return a * b // math.gcd(a, b)
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
LCM = 1
ans = 0
MOD = 1000000007
for x in A:
	LCM = lcm(LCM, x)
for x in A:
	ans += LCM // x
print(ans % MOD)


from fractions import *
n = int(input())
mod = 1000000007
s = [int(j) for j in input().split()]
ans = 1
for i in s:
	ans *= i // gcd(ans, i)
print(sum((ans // i for i in s)) % mod)


import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
lc = 1
for i in range(n):
	lc = lcm(lc, a[i])
ans = 0
for i in range(n):
	ans += lc * pow(a[i], -1, mod)
	ans %= mod
print(ans)


from itertools import groupby
from collections import Counter

def fast_prime_factorization_many(lst):
	from subprocess import Popen, PIPE
	res = Popen(['factor'] + list(map(str, lst)), stdout=PIPE).communicate()[0].split(b'\n')[:-1]
	return [Counter(list(map(int, r.split()[1:]))) for r in res]

def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print(1)
		return
	mod = int(1000000000.0 + 7)
	Factors = fast_prime_factorization_many(A)
	lcm = 1
	max_factor = [0] * 1000010
	for f in Factors:
		for (k, v) in list(f.items()):
			v_prev = max_factor[k]
			if v_prev < v:
				for i in range(v - v_prev):
					lcm = lcm * k % mod
				max_factor[k] = v
	ans = 0
	for a in A:
		wk = lcm * pow(a, mod - 2, mod)
		ans += wk
		ans %= mod
	print(ans)
	return
main()


import sys
from collections import defaultdict
mod = 10 ** 9 + 7

def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if tmp % i == 0:
			cnt = 0
			while tmp % i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr

def main():
	N = int(sys.stdin.readline().rstrip())
	A = [int(x) for x in sys.stdin.readline().rstrip().split()]
	p = defaultdict(int)
	for a in A:
		for (x, y) in factorization(a):
			p[x] = max(p[x], y)
	U = 1
	for (x, y) in p.items():
		U = U * pow(x, y, mod) % mod
	ans = 0
	for a in A:
		ans = (ans + U * pow(a, mod - 2, mod)) % mod
	print(ans)
main()


import math
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
lcmall = A[0]
for i in range(1, N):
	gcdall = math.gcd(lcmall, A[i])
	lcmall = lcmall * A[i] // gcdall
sum = 0
for i in range(N):
	B[i] = int(lcmall // A[i])
	sum += B[i]
print(sum % (10 ** 9 + 7))


import math
import itertools
MOD = 1000000007
N = list(map(int, input().split()))[0]
A = list(map(int, input().split()))
l = 1
for i in range(N):
	l = A[i] // math.gcd(A[i], l) * l
A = [l // x for x in A]
ans = list(itertools.accumulate(A))[-1]
ans %= MOD
print(ans)


from functools import reduce
from math import gcd
MOD = 10 ** 9 + 7
_ = int(input())
la = list(map(int, input().split()))

def inv(a):
	return pow(a, MOD - 2, MOD)

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

def addmod(a, b):
	return (a + b) % MOD
l = reduce(lcm, la) % MOD
answer = reduce(addmod, (l * inv(a) for a in la), 0)
print(answer)


n = int(input())
a = [int(j) for j in input().split()]
t = 1
mod = 10 ** 9 + 7
from fractions import *
for i in a:
	t *= i // gcd(t, i)
print(sum((t // i for i in a)) % mod)


import math
from functools import reduce
n = int(input())
a = list(map(int, input().split()))

def lcm(x, y):
	return x * y // math.gcd(x, y)
l = reduce(lcm, a)
b = list(map(lambda x: l // x, a))
m = 10 ** 9 + 7
print(sum(b) % m)


from functools import reduce
N = int(input())
(*A,) = map(int, input().split())
mod = 10 ** 9 + 7

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
LCM = reduce(lcm, A) % mod
print(sum([LCM * pow(A[i], -1, mod) % mod for i in range(N)]) % mod)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
MOD = 10 ** 9 + 7

def solve():
	N = Scanner.int()
	A = Scanner.map_int()
	l = 1
	for a in A:
		l = lcm(a, l)
	ans = 0
	for a in A:
		ans += l // a
	ans %= MOD
	print(ans)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
so_list = [0 for i in range(10 ** 6)]
mod = 10 ** 9 + 7

def fac(n):
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			if so_list[i] < cnt:
				so_list[i] = cnt
	if temp != 1:
		if so_list[temp] == 0:
			so_list[temp] = 1
for i in range(n):
	a1 = a[i]
	fac(a1)
l = 1
for i in range(len(so_list)):
	if so_list[i] != 0:
		l *= pow(i, so_list[i], mod)
		l %= mod
ans = 0
for i in a:
	t = pow(i, mod - 2, mod)
	ans += l * t % mod
print(ans % mod)


from math import gcd
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def lcm_base(x, y):
	return x * y // gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
num = lcm_list(A) % mod
ans = 0
for a in A:
	ans += num * pow(a, mod - 2, mod) % mod
ans %= mod
print(ans)


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

class Eratosthenes:

	def __init__(self, n):
		self.n = n
		self.min_factor = [-1] * (n + 1)
		(self.min_factor[0], self.min_factor[1]) = (0, 1)

	def get_primes(self):
		primes = []
		is_prime = [True] * (self.n + 1)
		is_prime[0] = is_prime[1] = False
		for i in range(2, self.n + 1):
			if not is_prime[i]:
				continue
			primes.append(i)
			self.min_factor[i] = i
			for j in range(i * 2, self.n + 1, i):
				is_prime[j] = False
				if self.min_factor[j] == -1:
					self.min_factor[j] = i
		return primes

	def prime_factorization(self, n):
		res = []
		while n != 1:
			prime = self.min_factor[n]
			exp = 0
			while self.min_factor[n] == prime:
				exp += 1
				n //= prime
			res.append([prime, exp])
		return res

def resolve():
	n = int(input())
	A = list(map(int, input().split()))
	MAX_A = max(A) + 1
	er = Eratosthenes(MAX_A)
	er.get_primes()
	num = [0] * MAX_A
	for i in range(n):
		pf = er.prime_factorization(A[i])
		for (p, ex) in pf:
			num[p] = max(num[p], ex)
	LCM = 1
	for v in range(2, MAX_A):
		LCM *= pow(v, num[v], mod)
		LCM %= mod
	res = 0
	for a in A:
		res += LCM * pow(a, mod - 2, mod)
		res %= mod
	print(res)

def __starting_point():
	resolve()
__starting_point()


import math
n = int(input())
a = list(map(int, input().split()))
s = a[0]
for i in a[1:]:
	s = s * i // math.gcd(s, i)
num = 0
for h in a:
	num += s // h
print(num % (10 ** 9 + 7))


from math import *

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
n = int(input())
a = [int(x) for x in input().split()]
mod = 1000000000 + 7
k = 1
for x in a:
	k = lcm(k, x)
ans = 0
for x in a:
	ans += k // x
print(ans % mod)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = 10 ** 9 + 7

def fact(N):
	res = {}
	tmp = N
	for i in range(2, int(N ** 0.5 + 1) + 1):
		cnt = 0
		while tmp % i == 0:
			cnt += 1
			tmp //= i
		if cnt > 0:
			res[i] = cnt
	if tmp != 1:
		res[tmp] = 1
	if res == {}:
		res[N] = 1
	return res

def modpow(n, p):
	res = 1
	while p > 0:
		if p & 1:
			res = res * n % MOD
		n = n * n % MOD
		p >>= 1
	return res

def modinv(n):
	(b, u, v) = (MOD, 1, 0)
	while b > 0:
		t = n // b
		n -= t * b
		(n, b) = (b, n)
		u -= t * v
		(u, v) = (v, u)
	u %= MOD
	if u < 0:
		u += MOD
	return u

def solve():
	N = Scanner.int()
	A = Scanner.map_int()
	L = defaultdict(int)
	for i in range(N):
		for (k, v) in list(fact(A[i]).items()):
			L[k] = max(L[k], v)
	lcm = 1
	for (k, v) in list(L.items()):
		lcm *= modpow(k, v)
		lcm %= MOD
	ans = 0
	for i in range(N):
		x = lcm * modinv(A[i]) % MOD
		ans += x
		ans %= MOD
	print(ans)

def main():
	solve()

def __starting_point():
	main()
__starting_point()