Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

def eratosthenes(N):
	is_prime = [True] * (N + 1)
	is_prime[0], is_prime[1] = False, False
	for i in range(2, int(N**(1/2)) + 1):
		if is_prime[i]:
			for j in range(i * 2, N + 1, i):
				is_prime[j] = False
	return [i for i in range(N+1) if is_prime[i]]

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
primes = eratosthenes(10**6+1)

tot_cnt = defaultdict(lambda: 0)

def factorization(num):
	tmp_cnt = defaultdict(lambda: 0)
	for p in primes:
		if p > num:
			break

		while True:
			if num % p == 0:
				num //= p
				tmp_cnt[p] += 1
			else:
				break

	return tmp_cnt

for a in A:
	T = factorization(a)
	for t in T:
		tot_cnt[t] = max(tot_cnt[t], T[t])

lcm = 1
for t in tot_cnt:
	lcm *= pow(t, tot_cnt[t], mod)
	lcm %= mod

ans = 0
for a in A:
	tmp = lcm * pow(a, mod-2, mod)
	ans += tmp
	ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD
LCM %= mod
ans = 0
for i in range(N):
	t = LCM * pow(A[i], mod-2, mod)
	ans += t
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

def eratosthenes(N):
	is_prime = [True] * (N + 1)
	is_prime[0], is_prime[1] = False, False
	for i in range(2, int(N**(1/2)) + 1):
		if is_prime[i]:
			for j in range(i * 2, N + 1, i):
				is_prime[j] = False
	return [i for i in range(N+1) if is_prime[i]]

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
primes = eratosthenes(10**6+1)

tot_cnt = defaultdict(lambda: 0)

def factorization(num):
	tmp_cnt = defaultdict(lambda: 0)
	for p in primes:
		if p > num:
			break

		while True:
			if num % p == 0:
				num //= p
				tmp_cnt[p] += 1
			else:
				break

	return tmp_cnt

for a in A:
	T = factorization(a)
	for t in T:
		tot_cnt[t] = max(tot_cnt[t], T[t])

lcm = 1
for t in tot_cnt:
	lcm *= pow(t, tot_cnt[t], mod)
	lcm %= mod

ans = 0
for a in A:
	tmp = lcm * pow(a, mod-2, mod)
	ans += tmp
	ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD
LCM %= mod
ans = 0
for i in range(N):
	t = LCM * pow(A[i], mod-2, mod)
	ans += t
	ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), np.int64)
mod = 10**9+7
LCM = np.lcm.reduce(A)
B = [LCM] * N
B = B // A
#print(LCM)
#print(B)
ans = 0
for i in range(N):
	t = B[i]%mod
	ans += t
	ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD
LCM %= mod
ans = 0
for i in range(N):
	t = LCM * pow(A[i], mod-2, mod)
	ans += t
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD

ans = 0
for i in range(N):
	ans += LCM//A[i]
	ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD
LCM %= mod
ans = 0
for i in range(N):
	t = LCM * pow(A[i], mod-2, mod)
	ans += t
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD

ans = 0
for i in range(N):
	ans += LCM//A[i]
	ans %= mod

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD
LCM %= mod
ans = 0
for i in range(N):
	t = LCM * pow(A[i], mod-2, mod)
	ans += t
	ans %= mod

print(ans)