Buggy python submission (verdict: Time Limit Exceeded):
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7
INF = float('inf')

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

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod
	
print(ans)


Fixed submission:
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7

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

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
lcm %= mod
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
input = sys.stdin.readline

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

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


lcm_lst = {}
lst_c = []
for i in lst_A:
	c = collections.Counter(prime_factorize(i))
	lst_c.append(c)
	for key in c:
		if key in lcm_lst:
			if(lcm_lst[key]<c[key]):
				lcm_lst[key]=c[key]
		else:
			lcm_lst[key]=c[key]

ans = 0
for c in lst_c:
	a = 1
	for key in lcm_lst:
		if key in c:
			a = (a * key **(lcm_lst[key] - c[key]))%mod
		else:
			a = (a * key **(lcm_lst[key]))%mod
	ans =  (ans + a )% mod
print(ans)

Fixed submission:
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7

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

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
lcm %= mod
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
input = sys.stdin.readline


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

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


lcm_lst = {}
lst_c = []
for i in lst_A:
	c = collections.Counter(prime_factorize(i))
	lst_c.append(c)
	for key in c:
		if key in lcm_lst:
			if(lcm_lst[key]<c[key]):
				lcm_lst[key]=c[key]
		else:
			lcm_lst[key]=c[key]

ans = 0
for c in lst_c:
	g = lcm_lst.copy()
	for key in c:
		g[key]=lcm_lst[key] - c[key]
	a = 1
	for key in g:
		a = (a * key**g[key]) % mod
	ans =  (ans + a )% mod
print(ans)

Fixed submission:
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7

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

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
lcm %= mod
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import collections
input = sys.stdin.readline


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

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


lcm_lst = {}
lst_c = []
for i in lst_A:
	c = collections.Counter(prime_factorize(i))
	lst_c.append(c)
	for key in c:
		if key in lcm_lst:
			if(lcm_lst[key]<c[key]):
				lcm_lst[key]=c[key]
		else:
			lcm_lst[key]=c[key]

ans = 0
for c in lst_c:
	g = lcm_lst.copy()
	for key in c:
		g[key]=lcm_lst[key] - c[key]
	a = 1
	for key in g:
		a = (a * key**g[key]) % mod
	ans =  (ans + a)% mod
print(ans)

Fixed submission:
import sys,fractions
input = sys.stdin.readline

mod = 10**9+7

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

lcm = 1
for a in lst_a:
    lcm = a*lcm//fractions.gcd(a,lcm)
lcm %= mod
ans = 0
for a in lst_a:
	ans += lcm*pow(a,mod-2,mod)
	ans %= mod

print(ans)