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


def factorization(n):
    dict = defaultdict(int)
    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
            dict[i] = cnt
    if temp != 1:
        dict[temp] = 1
    if not dict:
        dict[n] = 1
    return dict


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

prime_factors = defaultdict(int)
factors = []

for a in A:
    a_factors = factorization(a)
    for prime, count in a_factors.items():
        prime_factors[prime] = max(count, prime_factors[prime])
    factors.append(a_factors)

ans = 0
for a, div_factors in zip(A, factors):
    num = 1
    for prime, count in prime_factors.items():
        dived_count = count - div_factors[prime]
        num *= pow(prime, dived_count, mod)
    ans += num % mod

print(ans % mod)


Fixed submission:
import fractions


mod = 10 ** 9 + 7

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


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

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)

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


def factorization(n):
    dict = defaultdict(int)
    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
            dict[i] = cnt

    if temp != 1:
        dict[temp] = 1

    if not dict:
        dict[n] = 1

    return dict


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

prime_factors = defaultdict(int)
factors = []

for a in A:
    a_factors = factorization(a)
    for prime, count in a_factors.items():
        prime_factors[prime] = max(count, prime_factors[prime])
    factors.append(a_factors)

B = []
for a, div_factors in zip(A, factors):
    num = 1
    for prime, count in prime_factors.items():
        dived_count = count - div_factors[prime]
        num *= prime ** dived_count
    B.append(num)

print(sum(B)%mod)

Fixed submission:
import fractions


mod = 10 ** 9 + 7

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


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

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)

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


def factorization(n):
    dict = defaultdict(int)
    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
            dict[i] = cnt

    if temp != 1:
        dict[temp] = 1

    if not dict:
        dict[n] = 1

    return dict


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

prime_factors = defaultdict(int)
factors = []

for a in A:
    a_factors = factorization(a)
    for prime, count in a_factors.items():
        prime_factors[prime] = max(count, prime_factors[prime])
    factors.append(a_factors)

B = []
for a, div_factors in zip(A, factors):
    num = 1
    for prime, count in prime_factors.items():
        dived_count = count - div_factors[prime]
        num *= prime ** dived_count
    B.append(num)

print(sum(B)%mod)

Fixed submission:
import fractions


mod = 10 ** 9 + 7

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


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

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)

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


def factorization(n):
    dict = defaultdict(int)
    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
            dict[i] = cnt

    if temp != 1:
        dict[temp] = 1

    if not dict:
        dict[n] = 1

    return dict


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

prime_factors = defaultdict(int)
factors = []

for a in A:
    a_factors = factorization(a)
    for prime, count in a_factors.items():
        prime_factors[prime] = max(count, prime_factors[prime])
    factors.append(a_factors)

B = []
for a, div_factors in zip(A, factors):
    num = 1
    for prime, count in prime_factors.items():
        dived_count = count - div_factors[prime]
        num *= prime ** dived_count
        num %= mod
    B.append(num)

print(sum(B)%mod)

Fixed submission:
import fractions


mod = 10 ** 9 + 7

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


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

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import numpy as np


mod = 10 ** 9 + 7

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


n = int(input())
A = np.array(list(map(int, input().split())), dtype=np.uint64)

num = 1
for a in A:
    num = lcm(num, a)

B = np.array(num // A).astype('int64')
print(sum(B)%mod)

Fixed submission:
import fractions


mod = 10 ** 9 + 7

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


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

num = 1
for a in A:
    num = lcm(num, a)

ans = 0
for a in A:
    ans += num // a
print(ans%mod)