AtCoder Beginner Contest 152 - Flatten

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.

Source: atcoder | 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()


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


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 fractions import gcd
MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
now = A[0]
ans = 0
for i in range(1, N):
	now = now // gcd(now, A[i]) * A[i]
for i in range(N):
	ans += now // A[i]
print(ans % MOD)


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


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
from fractions import gcd
L = A[0]
for i in range(1, N):
	L = L * A[i] // gcd(L, A[i])
ans = 0
for i in range(N):
	ans += L // A[i]
print(ans % 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)


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
n = int(input())
a = [int(i) for i in input().split()]
l = 1
mod = 10 ** 9 + 7
for i in range(n):
	l = lcm(l, a[i])
ans = 0
for i in a:
	ans += l // i
print(ans % mod)


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)


from fractions import gcd
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in A:
	num = i // gcd(i, num) * num
for i in A:
	ans += num // i
print(int(ans % 1000000007))


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)


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
LCM = 1
for i in A:
	GCD = gcd(LCM, i)
	LCM = LCM * i // GCD
ans = 0
for i in A:
	ans += LCM // i
print(ans % mod)


import fractions
N = int(input())
A = list(map(int, input().split()))
a = 1
for i in range(N):
	g = a * A[i] // fractions.gcd(a, A[i])
	a = g
b = 0
for i in range(N):
	b = b + g // A[i]
c = b % 1000000007
print(c)


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)


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for k in a:
	l = l * k // gcd(l, k)
mod = 10 ** 9 + 7
ans = 0
for k in a:
	ans += l // k
print(int(ans) % mod)


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


import fractions
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1, n):
	l = l // fractions.gcd(l, a[i]) * a[i]
s = 0
for i in range(n):
	s += l // a[i]
print(s % 1000000007)


import fractions
mod = 1000000007
n = int(input())
a = list(map(int, input().split()))
LCM = 1
for i in a:
	LCM = LCM // fractions.gcd(LCM, i) * i
ans = 0
for i in a:
	ans += LCM // i
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()


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


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 fractions import gcd
from functools import reduce
n = int(input())
lst = list(map(int, input().split()))
ans = 0
mod = 10 ** 9 + 7
lcd = reduce(lambda x, y: x * y // gcd(x, y), lst)
for i in lst:
	ans += lcd // i
print(ans % 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)


from fractions import gcd
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
k = reduce(lambda x, y: x * y // gcd(x, y), a)
ans = sum(list(map(lambda x: k // x, a)))
print(ans % (10 ** 9 + 7))


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


from fractions import gcd
MOD = 10 ** 9 + 7
(N, *A) = map(int, open(0).read().split())

def lcm(a, b):
	return a * b // gcd(a, b)
s = 1
for i in A:
	s = lcm(s, i)
s %= MOD
ans = 0
for i in A:
	ans += s * pow(i, MOD - 2, 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 fractions as m
n = int(input())
a = input().split()
b = 1
for i in a:
	i = int(i)
	b *= i // m.gcd(b, i)
print(sum((b // int(i) for i in a)) % (10 ** 9 + 7))


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)


from fractions import gcd
mod = 10 ** 9 + 7
(N, *A) = map(int, open(0).read().split())
L = 1
for a in A:
	L = L // gcd(L, a) * a
L %= mod
print(sum((L * pow(a, mod - 2, mod) for a in A)) % mod)


from fractions import gcd
N = int(input())
A = list(map(int, input().split(' ')))
L = 1

def lcm(x, y):
	return x // gcd(x, y) * y
for a in A:
	L = lcm(L, a)
ans = 0
for a in A:
	ans += L // a
print(ans % (10 ** 9 + 7))


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)


M = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
import fractions as f
(l, r) = (a[0], 1)
for i in range(1, n):
	g = f.gcd(l, a[i])
	(s, t) = (l // g, a[i] // g)
	(l, r) = (s * t * g, (r * t + s) % M)
print(r)


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


import fractions
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(1)
	return
g = fractions.gcd(a[0], a[1])
f = a[0] * a[1] // g
ans = a[0] // g + a[1] // g
for i in range(2, n):
	h = fractions.gcd(f, a[i])
	g = a[i] // h
	f = f * a[i] // h
	ans *= g
	ans += f // a[i]
	ans %= mod
print(ans % mod)


import fractions
n = int(input())
a = list(map(int, input().split()))
l = 1
for i in a:
	m = l
	l = fractions.gcd(m, i)
	l = i * m // l
p = 0
for i in a:
	p += l // i
print(p % (10 ** 9 + 7))


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
L = a[0]

def lcm(x, y):
	return x // gcd(x, y) * y
for i in a:
	L = lcm(L, i)
print(sum([L // i for i in a]) % mod)


from fractions import gcd
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
x = reduce(lambda x, y: y // gcd(x, y) * x, a)
ans = 0
for i in a:
	ans += x // i
ans %= 1000000007
print(ans)


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()


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
res = 0
l = A[0]
for i in range(1, N):
	l = l * A[i] // gcd(l, A[i])
for a in A:
	res += l // a
print(res % 1000000007)


import fractions
n = int(input())
A = list(map(int, input().split()))
a = A[0]
for b in A:
	a = a * b // fractions.gcd(a, b)
count = 0
for i in A:
	count += a // i
print(count % (10 ** 9 + 7))


from fractions import gcd
MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
a_lcm = a[-1]
for ai in a:
	a_lcm = a_lcm * ai // gcd(a_lcm, ai)
sum_b = 0
for ai in a:
	bi = a_lcm // ai
	sum_b += bi
print(sum_b % MOD)


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)


import fractions
N = int(input())
A = list(map(int, input().split()))
c = 1
a = 0
w = 10 ** 9 + 7
for A_ in A:
	c = c * A_ // fractions.gcd(c, A_)
for A_ in A:
	a += c // A_
print(int(a % w))


from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
lcm = A[0]
MOD = 10 ** 9 + 7
for a in A:
	lcm = lcm // gcd(lcm, a) * a
res = 0
for a in A:
	res += lcm // a
print(res % MOD)


N = int(input())
A = list(map(int, input().split()))
from fractions import gcd
mod = 10 ** 9 + 7
g = A[0]
for a in A[1:]:
	g = g * a // gcd(g, a)
ans = 0
b = g % mod
for a in A:
	ans += b * pow(a, mod - 2, mod)
	ans %= mod
print(ans % mod)


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


from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
lcm = reduce(lambda a, b: a * b // gcd(a, b), A)
print(sum((lcm // a for a in A)) % 1000000007)


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))


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


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)


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
g = A[0]
l = A[0]
for i in range(N):
	g = gcd(l, A[i])
	l = l * A[i] // g
ans = 0
mod = 10 ** 9 + 7
for i in range(N):
	ans += l // A[i]
print(ans % mod)


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)


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


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)


n = int(input())
a = [int(x) for x in input().split()]
mod = 10 ** 9 + 7
lcm = 1
from fractions import gcd
for ai in a:
	lcm = ai * lcm // gcd(ai, lcm)
ans = 0
for ai in a:
	ans += lcm // ai
print(ans % mod)


import fractions
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
div = a[0]
for i in a[1:]:
	div = div * i // fractions.gcd(div, i)
ans = 0
for i in a:
	ans += div // i
print(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()


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


import sys
import math
import fractions
from collections import defaultdict
from functools import reduce
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(stdin.readline().rstrip())
nm = lambda : list(map(int, stdin.readline().split()))
nl = lambda : list(map(int, stdin.readline().split()))
INF = 10 ** 18
mod = 10 ** 9 + 7
N = int(input())
A = nl()
ans = 0
min_bai = 1
for i in range(N):
	min_bai = min_bai * A[i] // fractions.gcd(min_bai, A[i])
for i in range(N):
	ans += min_bai // A[i]
print(ans % mod)


import fractions
n = int(input())
l = list(map(int, input().split()))
b = 0
c = 0
for i in range(n):
	if i == 0:
		b = l[i]
	else:
		b = b * l[i] // fractions.gcd(l[i], b)
for i in range(n):
	c += b // l[i]
print(c % 1000000007)


from fractions import gcd
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
lcm = 1
for i in A:
	lcm = lcm * i // gcd(lcm, i)
ans = 0
for i in A:
	ans += lcm // i
print(ans % MOD)


def make_prime_table(n):
	sieve = list(range(n + 1))
	sieve[0] = -1
	sieve[1] = -1
	for i in range(4, n + 1, 2):
		sieve[i] = 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i] != i:
			continue
		for j in range(i * i, n + 1, i * 2):
			if sieve[j] == j:
				sieve[j] = i
	return sieve

def prime_factorize(n):
	result = []
	while n != 1:
		p = prime_table[n]
		e = 0
		while n % p == 0:
			n //= p
			e += 1
		result.append((p, e))
	return result
N = int(input())
A = list(map(int, input().split()))
m = 1000000007
prime_table = make_prime_table(10 ** 6)
lcm_factors = {}
for a in A:
	for (p, e) in prime_factorize(a):
		if p not in lcm_factors or lcm_factors[p] < e:
			lcm_factors[p] = e
lcm = 1
for p in lcm_factors:
	lcm *= pow(p, lcm_factors[p], m)
	lcm %= m
result = 0
for i in range(N):
	result += lcm * pow(A[i], m - 2, m)
	result %= m
print(result)


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()


from fractions import gcd
from functools import reduce
n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
lcm = reduce(lambda x, y: x * y // gcd(x, y), A)
ans = sum((lcm // x for x in A))
ans %= mod
print(ans)


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)


max_A = 1000000
N = int(input())
A = list(map(int, input().split()))
m = 1000000007
sieve = [0] * (max_A + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, max_A + 1):
	if sieve[i] != 0:
		continue
	sieve[i] = i
	for j in range(i * i, max_A + 1, i):
		if sieve[j] == 0:
			sieve[j] = i
lcm_factors = {}
for i in range(N):
	t = []
	a = A[i]
	while a != 1:
		if len(t) != 0 and t[-1][0] == sieve[a]:
			t[-1][1] += 1
		else:
			t.append([sieve[a], 1])
		a //= sieve[a]
	for (k, v) in t:
		if k not in lcm_factors or lcm_factors[k] < v:
			lcm_factors[k] = v
lcm = 1
for k in lcm_factors:
	for i in range(lcm_factors[k]):
		lcm *= k
		lcm %= m
result = 0
for i in range(N):
	result += lcm * pow(A[i], m - 2, m)
	result %= m
print(result)


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 fractions
N = int(input())
T = list(map(int, input().split()))
lcm = T[0]
ans = 0
MOD = 1000000007
for i in range(1, N):
	lcm = lcm * T[i] // fractions.gcd(lcm, T[i])
for x in T:
	ans += lcm // x
print(ans % MOD)


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

def lcm(a, b):
	return a * b // gcd(a, b)
l = reduce(lcm, a)
mod = pow(10, 9) + 7
ans = 0
for x in a:
	ans += l // x
print(ans % mod)


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
l = A[0]
for a in A:
	l = l * a // gcd(l, a)
num = 0
for a in A:
	num += l // a
print(num % (10 ** 9 + 7))


import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter, defaultdict, deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inpm():
	return list(map(int, input().split()))

def inpl():
	return list(map(int, input().split()))

def inpls():
	return list(input().split())

def inplm(n):
	return list((int(input()) for _ in range(n)))

def inplL(n):
	return [list(input()) for _ in range(n)]

def inplT(n):
	return [tuple(input()) for _ in range(n)]

def inpll(n):
	return [list(map(int, input().split())) for _ in range(n)]

def inplls(n):
	return sorted([list(map(int, input().split())) for _ in range(n)])
n = inp()
A = inpl()

def lcm(A):
	from fractions import gcd
	x = A[0]
	for a in A:
		x = x * a // math.gcd(x, a)
	return x
l = lcm(A)
ans = 0
for a in A:
	ans += l // a
print(ans % mod)


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


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
t = 1
mod = 10 ** 9 + 7
for i in A:
	t *= i // gcd(t, i)
ans = sum((t // i for i in A))
print(ans % mod)


import fractions

def lcm(x, y):
	return x * y // fractions.gcd(x, y)
N = int(input())
A = [int(x) for x in input().split()]
a = 1
MOD = 10 ** 9 + 7
for i in A:
	a = lcm(a, i)
ans = 0
for i in A:
	ans += a // i
print(ans % MOD)


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

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
lcm = lambda a, b: a * b // gcd(a, b)
t = 1
for x in l:
	t = lcm(t, x)
print(sum((t // x for x in l)) % mod)


import math
import fractions
MOD = 1000000007
n = int(input())
a = list(map(int, input().split()))
x = 1
ans = 0
for i in a:
	x = x * i // fractions.gcd(x, i)
for i in a:
	ans = ans + x // i
print(ans % MOD, '\n')


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
from fractions import gcd
input = sys.stdin.readline
n = input()
arr = list(map(int, input().split()))
tmp = arr[0]
for i in arr:
	tmp = tmp * i // gcd(tmp, i)
print(sum((tmp // a for a in arr)) % (10 ** 9 + 7))


import fractions
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
l = 1
for i in A:
	l = l * i // fractions.gcd(l, i)
sum = 0
for i in A:
	sum += l // i
print(int(sum % mod))


import fractions

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


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


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()


import sys
input = sys.stdin.readline
from collections import defaultdict

class PrimeFactor:

	def __init__(self, n):
		self.n = n
		self.table = list(range(n + 1))
		self.table[2::2] = [2] * (n // 2)
		for p in range(3, int(n ** 0.5) + 2, 2):
			if self.table[p] == p:
				self.table[p * p::2 * p] = [p] * ((n - p * p - 1) // (2 * p) + 1)

	def is_prime(self, x):
		if x < 2:
			return False
		return self.table[x] == x

	def prime_factors(self, x):
		res = []
		if x < 2:
			return res
		while self.table[x] != 1:
			res.append(self.table[x])
			x //= self.table[x]
		return res

	def prime_counter(self, x):
		res = defaultdict(int)
		if x < 2:
			return res
		while self.table[x] != 1:
			res[self.table[x]] += 1
			x //= self.table[x]
		return res

	def prime_gcd(self, X):
		exponents = self.prime_counter(X[0])
		for x in X[1:]:
			Y = self.prime_counter(x)
			for (prime, exp) in exponents.items():
				if Y[prime] < exp:
					exponents[prime] = Y[prime]
		res = 1
		for (prime, exp) in exponents.items():
			res *= pow(prime, exp)
		return res

	def prime_lcm(self, X, mod=None):
		exponents = defaultdict(int)
		for x in X:
			for (prime, exp) in self.prime_counter(x).items():
				if exp > exponents[prime]:
					exponents[prime] = exp
		res = 1
		for (prime, exp) in exponents.items():
			res *= pow(prime, exp, mod)
		if mod == None:
			return res
		else:
			return res % mod
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
table = PrimeFactor(10 ** 6)
num = table.prime_lcm(A, mod)
res = 0
for a in A:
	res += num * pow(a, mod - 2, mod)
print(res % mod)


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))


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
	ans = ans * i // gcd(ans, i)
mod = 10 ** 9 + 7
print(sum(map(lambda x: ans // x, a)) % mod)


from fractions import gcd
from functools import reduce
n = int(input())
aaa = list(map(int, input().split()))
lcm = reduce(lambda a, b: a * b // gcd(a, b), aaa)
print(sum((lcm // a for a in aaa)) % 1000000007)


import sys
import math
import fractions
from collections import defaultdict
from functools import reduce
import collections
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(stdin.readline().rstrip())
nm = lambda : map(int, stdin.readline().split())
nl = lambda : list(map(int, stdin.readline().split()))
INF = 10 ** 18
mod = 10 ** 9 + 7
N = int(input())
A = nl()
NMAX = 10 ** 6

class Sieve:

	def __init__(self, n):
		self.n = n
		self.f = [0] * (n + 1)
		self.prime = []
		self.f[0] = self.f[1] = -1
		for i in range(2, n + 1):
			if self.f[i]:
				continue
			else:
				self.prime.append(i)
				self.f[i] = i
				for j in range(i * i, n + 1, i):
					if ~self.f[j]:
						self.f[j] = i

	def isProme(self, x):
		return self.f[x] == x

	def factorList(self, x):
		res = []
		while x != 1:
			res.append(self.f[x])
			x //= self.f[x]
		return res

	def factor(self, x):
		fl = self.factorList(x)
		return collections.Counter(fl)

def get_sieve_of_eratosthenes(n):
	prime = [2]
	limit = int(n ** 0.5)
	data = [i + 1 for i in range(2, n, 2)]
	while True:
		p = data[0]
		if limit <= p:
			return prime + data
		prime.append(p)
		data = [e for e in data if e % p != 0]
sieve = Sieve(10 ** 6)
mp = defaultdict(int)
for i in range(N):
	f = sieve.factor(A[i])
	for (key, val) in f.items():
		mp[key] = max(val, mp[key])
lcm = 1
for (key, val) in mp.items():
	lcm *= key ** val
ans = 0
for i in range(N):
	ans += lcm // A[i]
print(ans % mod)


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
ans = 0
MOD = 1000000007
LCM = A[0]
for i in range(1, N):
	LCM *= A[i] // gcd(LCM, A[i])
for a in A:
	ans += LCM // a
print(ans % MOD)


from fractions import gcd
from functools import reduce
(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)) % 1000000007)


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)


from fractions import gcd

def main():
	N = int(input())
	a_list = list(map(int, input().split()))
	MOD = 10 ** 9 + 7
	a_lcm = a_list[0]
	for a in a_list[1:]:
		a_lcm *= a // gcd(a, a_lcm)
	res = 0
	for a in a_list:
		res += a_lcm // a
	print(res % MOD)

def __starting_point():
	main()
__starting_point()


from functools import reduce
from fractions import gcd
from collections import defaultdict, Counter
import copy
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
dic = defaultdict(int)

def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
for i in a:
	c = Counter(prime_factorize(i))
	for (j, k) in c.items():
		if dic[j] < k:
			dic[j] = k
l = 1
for (i, j) in dic.items():
	l *= pow(i, j, mod)
point = 0
for i in a:
	point += l * pow(i, mod - 2, mod)
	point %= mod
print(point % mod)


import sys
read = sys.stdin.buffer.read
from fractions import gcd
(N, *A) = map(int, read().split())
lcm = 1
answer = 0
for x in A:
	n = x // gcd(lcm, x)
	lcm *= n
	answer *= n
	answer += lcm // x
answer %= 10 ** 9 + 7
print(answer)


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)


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
l = 1
for a in A:
	l = a * l // gcd(a, l)
ans = 0
for a in A:
	ans += l // a
print(ans % 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 gcd

def lcm(a, b):
	return a // gcd(a, b) * b
n = int(input())
a = [int(i) for i in input().split()]
L = a[0]
for i in a:
	L = lcm(L, i)
ans = 0
for i in a:
	ans += L // i
print(ans % (10 ** 9 + 7))


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


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


from fractions import gcd
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 0
l = 1
for i in a:
	l = l * i // gcd(l, i)
l %= mod
for i in a:
	ans = (ans + l * pow(i, mod - 2, mod)) % mod
print(ans)


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)


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
b = 1
for i in a:
	b = b // gcd(b, i) * i
ans = 0
for i in a:
	ans += b // i
print(ans % (10 ** 9 + 7))


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = a[i] * lcm // gcd(a[i], lcm)
b = [lcm // a[i] for i in range(n)]
print(sum(b) % (10 ** 9 + 7))


from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = A[0]
for a in A[1:]:
	L = L * a // gcd(L, a)
ans = 0
for a in A:
	ans += L // a
print(ans % 1000000007)


from fractions import gcd
n = input()
s = list(map(int, input().split()))
L = 1
for i in s:
	L = L * i // gcd(L, i)
ans = 0
for j in s:
	ans += L // j
print(ans % (10 ** 9 + 7))


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()


import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
lcm_ = 1
for a in A:
	lcm_ = lcm(lcm_, a)
ans = 0
for a in A:
	ans += lcm_ // a
ans %= MOD
print(ans)


import sys
from fractions import gcd
input = sys.stdin.readline

def main():
	MOD = 10 ** 9 + 7
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print(1)
		return
	l = A[0] * A[1] // gcd(A[0], A[1])
	for i in range(2, N):
		l = l * A[i] // gcd(A[i], l - A[i])
	l %= MOD
	ans = 0
	for i in range(N):
		ans += l * pow(A[i], MOD - 2, MOD)
		ans %= MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


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


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
N = int(input())
A = list(map(int, input().split()))
M = 10 ** 9 + 7
l = 1
for a in A:
	l = lcm(l, a)
ans = 0
for a in A:
	ans += l // a
print(ans % M)


import fractions
n = int(input())
t = list(map(int, input().split()))
x = 0
ans = t[0]
for i in range(1, n):
	ans = ans * t[i] // fractions.gcd(ans, t[i])
for j in range(n):
	x += ans // t[j]
print(x % (10 ** 9 + 7))


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)


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
	l = i * l // gcd(i, l)
cnt = 0
for i in a:
	cnt += l // i
print(cnt % mod)


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


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
l = 1
for i in range(n):
	l = l * a[i] // gcd(l, a[i])
ans = 0
for i in range(n):
	ans += l // 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)


(n, *a) = map(int, open(0).read().split())
MOD = 10 ** 9 + 7
from fractions import gcd

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

def inv(x):
	return pow(x, MOD - 2, MOD)
L = 1
for i in a:
	L = lcm(L, i)
L = L % MOD
ans = 0
for i in a:
	ans = (ans + L * inv(i)) % MOD
print(ans)


from fractions import gcd
from functools import reduce
N = int(input())
(*A,) = map(int, input().split())
mod = 10 ** 9 + 7
lcm = reduce(lambda a, b: a * b // gcd(a, b), A)
print(sum(map(lambda x: lcm // x, A)) % mod)


from fractions import gcd
from functools import reduce
lcm = lambda x, y: x // gcd(x, y) * y
MOD = 10 ** 9 + 7
n = int(input())
A = list(map(int, input().split()))
c = sum((pow(a, MOD - 2, MOD) for a in A)) % MOD
l = reduce(lcm, A) % MOD
print(c * l % MOD)


import fractions

def lcm(a, b):
	return a * b // fractions.gcd(a, b)
N = int(input())
nums = list(map(int, input().split()))
num = 1
for i in nums:
	num = lcm(num, i)
print(sum([num // i for i in nums]) % (10 ** 9 + 7))


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


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 gcd
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
M = 1
for a in A:
	M = M * a // gcd(M, a)
M %= mod
count = 0
for a in A:
	count = (count + M * pow(a, mod - 2, mod)) % mod
print(count)


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)


n = int(input())
a = tuple(map(int, input().split()))
import fractions
lcm = a[0]
b_sum = 0
for i in range(1, n):
	lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
num = 10 ** 9 + 7
for i in range(n):
	b_sum += lcm // a[i]
print(b_sum % num)


from fractions import gcd
N = int(input())
A_List = list(map(int, input().split()))
LCM = 1
for i in A_List:
	LCM = LCM * i // gcd(LCM, i)
ans = 0
for i in A_List:
	ans += LCM // i
print(ans % (10 ** 9 + 7))


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)


N = int(input())
n = input()
m = n.split()
p = [int(i) for i in m]
a = 0
b = 1
import fractions
for i in p:
	c = fractions.gcd(i, b)
	a = (a * i // c + b // c) % 1000000007
	b = b * i // c
print(a)


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 gcd
from functools import reduce
mod = 10 ** 9 + 7
n = int(input())
a = [int(i) for i in input().split()]
l = reduce(lambda x, y: x // gcd(x, y) * y, a)
ans = sum(map(lambda x: l // x, a))
print(ans % mod)


import sys
input = sys.stdin.buffer.readline
n = int(input())
l = list(map(int, input().split()))
f = l[0]
from fractions import gcd
for i in l:
	f = f * i // gcd(f, i)
mod = 10 ** 9 + 7
ans = 0
for i in l:
	ans += f // i
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 fractions import gcd
n = int(input())
a = [int(x) for x in input().split()]
g = a[0]
for i in a:
	g = i * g // gcd(i, g)
ans = 0
for i in range(n):
	ans += int(g // a[i])
print(ans % (10 ** 9 + 7))


from fractions import gcd
P = 10 ** 9 + 7
N = int(input())
S = list(map(int, input().split()))
temp = S[0]
for i in range(1, N):
	temp = temp * S[i] // gcd(temp, S[i])
temp %= P
ans = 0
for num in S:
	ans = (temp * pow(num, P - 2, P) % P + ans) % P
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 fractions
N = int(input())
A = [int(i) for i in input().split()]

def lcm(a, b):
	return a * b // fractions.gcd(a, b)
a_lcm = A[0]
for a in A[1:]:
	a_lcm = lcm(a_lcm, a)
ans = 0
for a in A:
	ans += a_lcm // a
print(ans % (10 ** 9 + 7))


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))


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


import fractions
N = int(input())
a = list(map(int, input().split()))
c = a[0]
b = 1
if N > 1:
	for i in range(1, N):
		d = fractions.gcd(c, a[i])
		b = b * a[i] // d + c // d
		b %= 10 ** 9 + 7
		c = c * a[i] // d
print(b)


import math
MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
A.sort()
MAX = max(A[-1], 2)
C = [0 for _ in range(MAX + 1)]
for a in A:
	C[a] += 1
ans = 1
P = [1 for _ in range(MAX + 1)]
P[0] = 0
P[1] = 0
S = [0 for _ in range(MAX + 1)]
for i in range(MAX + 1):
	if P[i] == 0:
		continue
	k = i * 2
	while k <= MAX:
		P[k] = 0
		k += i
	ind = 0
	k = 1
	while k <= MAX:
		k *= i
		ind += 1
	k = k // i
	ind -= 1
	while k > 1:
		l = k
		flag = False
		while l <= MAX:
			if C[l] > 0:
				flag = True
				break
			l += k
		if flag:
			break
		k = k // i
		ind -= 1
	S[i] = ind
	ans *= pow(i, ind, MOD)
	ans %= MOD

def xgcd(a, b):
	(x0, y0, x1, y1) = (1, 0, 0, 1)
	while b != 0:
		(q, a, b) = (a // b, b, a % b)
		(x0, x1) = (x1, x0 - q * x1)
		(y0, y1) = (y1, y0 - q * y1)
	return (a, x0, y0)

def modinv(a, m):
	(g, x, y) = xgcd(a, m)
	return x % m
B = [0 for _ in range(MAX + 1)]
ans_2 = 0
for a in A:
	if B[a] > 0:
		ans_2 += B[a]
	else:
		B[a] = modinv(a, MOD)
		ans_2 += B[a]
	ans_2 %= MOD
print(ans * ans_2 % MOD)


import fractions
c = 0
N = int(input())
L = list(map(int, input().split()))
a = L[0]
for i in range(1, N):
	a = L[i] * a // fractions.gcd(L[i], a)
for i in range(N):
	c += a // L[i]
print(c % (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)


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


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)


from fractions import gcd
n = int(input())
aaa = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm = aaa[0]
for a in aaa[1:]:
	lcm = lcm * a // gcd(lcm, a)
ans = sum((lcm // a for a in aaa)) % MOD
print(ans)


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 fractions import gcd
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
	l = x * l // gcd(x, l)
l %= mod
for x in a:
	res += l * pow(x, mod - 2, mod)
	res %= mod
print(res)


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


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 fractions import gcd
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
lcm = 1
for s in A:
	lcm = s * lcm // gcd(lcm, s)
ans = lcm * sum([pow(s, mod - 2, mod) for s in A]) % mod
print(int(ans % mod))


from fractions import gcd
s = int(input())
t = list(map(int, input().split()))
ans = t[0]
for i in t:
	ans = ans * i // gcd(ans, i)
mod = 10 ** 9 + 7
a = 0
for j in t:
	a += ans // j
print(int(a) % mod)


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
l = 1
for x in a:
	l = l * x // gcd(l, x)
ans = 0
for x in a:
	ans += l // x
print(ans % (10 ** 9 + 7))


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)


N = int(input())
A = [int(x) for x in input().split()]
import fractions
G = A[0]
for i in range(1, N):
	G = G * A[i] // fractions.gcd(G, A[i])
ans = 0
for j in range(N):
	ans += G // A[j]
print(ans % (10 ** 9 + 7))


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 fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
	AB = AB * i // fractions.gcd(AB, i)
sumB = 0
for i in A:
	sumB += AB // i
print(int(sumB % (10 ** 9 + 7)))


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 fractions import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
n = int(input())
a = [int(x) for x in input().split()]
sum = 0
G = 1
for elem in a:
	G = lcm(G, elem)
for elem in a:
	sum += G // elem
print(sum % 1000000007)


import fractions
mod = 10 ** 9 + 7

def lcm(m, n):
	return m // fractions.gcd(m, n) * n
n = int(input())
a = list(map(int, input().split()))
l = a[0]
ans = 0
for i in a:
	l = lcm(i, l)
for i in a:
	ans += l * pow(i, mod - 2, mod) % mod
print(ans % mod)


import sys
MOD = 10 ** 9 + 7
n = int(input())
a = [int(i) for i in sys.stdin.readline().split()]
from fractions import gcd
m = a[0]
for i in a:
	m = i // gcd(m, i) * m
ans = 0
for i in a:
	ans += m // i
print(ans % MOD)


import fractions
n = int(input())
a = [int(i) for i in input().split()]
g = 1
dx = fractions.gcd
for i in a:
	g *= i // dx(g, i)
suml = 0
mod = 10 ** 9 + 7
for i in a:
	suml += g * pow(i, mod - 2, mod)
	suml %= mod
print(suml)


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)


n = int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
	lcm = lcm * i // fractions.gcd(lcm, i)
b = []
for i in a:
	b.append(lcm // i)
ans = sum(b) % (10 ** 9 + 7)
print(ans)


from fractions import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
	s = lcm(s, i)
ans = 0
for i in a:
	ans += s // i
print(ans % 1000000007)


import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
	ans = ans * a[i] // fractions.gcd(ans, a[i])
count = 0
for ai in a:
	count += ans // ai
print(count % 1000000007)


from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
lcd = A[0]
for i in A:
	lcd = lcd * i // gcd(lcd, i)
ans = 0
for i in A:
	ans += lcd // i
print(ans % (10 ** 9 + 7))


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


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


import fractions
N = int(input())
A = list(map(int, input().split(' ')))
lcm = 1
for a in A:
	lcm *= a // fractions.gcd(lcm, a) % (10 ** 9 + 7)
for i in range(len(A)):
	A[i] = lcm // A[i]
print(sum(A) % (10 ** 9 + 7))


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
input()
a = [int(i) for i in input().split()]
l = a[0]
for i in a:
	l = lcm(i, l)
s = 0
for i in a:
	s += l // i
print(s % 1000000007)


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()


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
M = 10 ** 9 + 7
pre = a[0]
for v in a[1:]:
	pre = pre * v // gcd(pre, v)
print(sum((pre // v for v in a)) % M)


from functools import reduce
from fractions import gcd
n = int(input())
A = list(map(int, input().split()))
lc = reduce(lambda a, b: a * b // gcd(a, b), A)
b = [lc // i for i in A]
print(sum(b) % (1000 * 1000000 + 7))


from functools import reduce
from fractions import gcd
mod = 10 ** 9 + 7
(n, *A) = map(int, open(0).read().split())
if len(A) == 1:
	print(1)
else:
	l = reduce(lambda x, y: x * y // gcd(x, y), A) % mod
	s = 0
	for a in A:
		s += l * pow(a, mod - 2, mod)
		s %= mod
	print(s)