Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7
 
N = int(input())
A = list(map(int,input().split()))
fact = [1]*(10**7+10)
rfact = [1]*(10**7+10)
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
value = lcm_list(A)
ans = 0
for i in range(N):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Fixed submission:
import fractions
from functools import reduce
# Python3 program to compute LCM of 
# array elements modulo M
MAX = 10**6+1
mod = 1000000007
prime = [0 for i in range(MAX)] 
max_map = dict() 
# function to return a^n 
def power(a, n):
	if n == 0: 
		return 1
	p = power(a, n // 2) % mod
	p = (p * p) % mod
	if n & 1: 
		p = (p * a) % mod
	return p 

# function to find the smallest prime
# factors of numbers upto MAX
def sieve(): 
	prime[0], prime[1] = 1, 1
	for i in range(2, MAX): 
		if prime[i] == 0: 
			for j in range(i * 2, MAX, i): 
				if prime[j] == 0: 
					prime[j] = i 
			prime[i] = i 

# function to return the LCM modulo M 
def lcmModuloM(arr, n): 
	for i in range(n): 
		num = arr[i] 
		temp = dict() 
		# temp stores mapping of prime factors 
		# to its power for the current element 
		while num > 1:
			# factor is the smallest prime
			# factor of num
			factor = prime[num]
			# Increase count of factor in temp
			if factor in temp.keys():
				temp[factor] += 1
			else:
				temp[factor] = 1
			# Reduce num by its prime factor
			num = num // factor
		for i in temp:
			# store the higest power of every prime
			# found till now in a new map max_map
			if i in max_map.keys():
				max_map[i] = max(max_map[i], temp[i])
			else: 
				max_map[i] = temp[i]
	ans = 1
	for i in max_map:
		ans = (ans * power(i, max_map[i])) % mod
	return ans
# Driver code
sieve()
X = int(input())
A = list(map(int,input().split()))
N = max(A)
value = lcmModuloM(A, X)
ans = 0
for i in range(X):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = int(input())
A = list(map(int,input().split()))
fact = [1]*(10**7+10)
rfact = [1]*(10**7+10)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

value = lcm_list(A)
ans = 0
for i in range(N):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Fixed submission:
import fractions
from functools import reduce
# Python3 program to compute LCM of 
# array elements modulo M
MAX = 10**6+1
mod = 1000000007
prime = [0 for i in range(MAX)] 
max_map = dict() 
# function to return a^n 
def power(a, n):
	if n == 0: 
		return 1
	p = power(a, n // 2) % mod
	p = (p * p) % mod
	if n & 1: 
		p = (p * a) % mod
	return p 

# function to find the smallest prime
# factors of numbers upto MAX
def sieve(): 
	prime[0], prime[1] = 1, 1
	for i in range(2, MAX): 
		if prime[i] == 0: 
			for j in range(i * 2, MAX, i): 
				if prime[j] == 0: 
					prime[j] = i 
			prime[i] = i 

# function to return the LCM modulo M 
def lcmModuloM(arr, n): 
	for i in range(n): 
		num = arr[i] 
		temp = dict() 
		# temp stores mapping of prime factors 
		# to its power for the current element 
		while num > 1:
			# factor is the smallest prime
			# factor of num
			factor = prime[num]
			# Increase count of factor in temp
			if factor in temp.keys():
				temp[factor] += 1
			else:
				temp[factor] = 1
			# Reduce num by its prime factor
			num = num // factor
		for i in temp:
			# store the higest power of every prime
			# found till now in a new map max_map
			if i in max_map.keys():
				max_map[i] = max(max_map[i], temp[i])
			else: 
				max_map[i] = temp[i]
	ans = 1
	for i in max_map:
		ans = (ans * power(i, max_map[i])) % mod
	return ans
# Driver code
sieve()
X = int(input())
A = list(map(int,input().split()))
N = max(A)
value = lcmModuloM(A, X)
ans = 0
for i in range(X):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
fact = [1]*(N+1)
rfact = [1]*(10**7)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % mod
rfact[N] = r = pow(fact[N], mod-2, mod)
value = lcm_list(A)
ans = 0
for i in range(N):
    ans += value//A[i]
    #ans += value*rfact[A[i]]
    #print(value,A[i],mod)
    #ans += (value*rfact[A[i]])%mod
    #print(value,A[i],rfact[A[i]],mod)
print(ans%mod)

Fixed submission:
import fractions
from functools import reduce
# Python3 program to compute LCM of 
# array elements modulo M
MAX = 10**6+1
mod = 1000000007
prime = [0 for i in range(MAX)] 
max_map = dict() 
# function to return a^n 
def power(a, n):
	if n == 0: 
		return 1
	p = power(a, n // 2) % mod
	p = (p * p) % mod
	if n & 1: 
		p = (p * a) % mod
	return p 

# function to find the smallest prime
# factors of numbers upto MAX
def sieve(): 
	prime[0], prime[1] = 1, 1
	for i in range(2, MAX): 
		if prime[i] == 0: 
			for j in range(i * 2, MAX, i): 
				if prime[j] == 0: 
					prime[j] = i 
			prime[i] = i 

# function to return the LCM modulo M 
def lcmModuloM(arr, n): 
	for i in range(n): 
		num = arr[i] 
		temp = dict() 
		# temp stores mapping of prime factors 
		# to its power for the current element 
		while num > 1:
			# factor is the smallest prime
			# factor of num
			factor = prime[num]
			# Increase count of factor in temp
			if factor in temp.keys():
				temp[factor] += 1
			else:
				temp[factor] = 1
			# Reduce num by its prime factor
			num = num // factor
		for i in temp:
			# store the higest power of every prime
			# found till now in a new map max_map
			if i in max_map.keys():
				max_map[i] = max(max_map[i], temp[i])
			else: 
				max_map[i] = temp[i]
	ans = 1
	for i in max_map:
		ans = (ans * power(i, max_map[i])) % mod
	return ans
# Driver code
sieve()
X = int(input())
A = list(map(int,input().split()))
N = max(A)
value = lcmModuloM(A, X)
ans = 0
for i in range(X):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)