Buggy python submission (verdict: Runtime Error):
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)

    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)


if __name__ == '__main__':
    resolve()


Fixed submission:
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)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
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 // a
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Fixed submission:
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)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
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 // a
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Fixed submission:
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)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
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 // a
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Fixed submission:
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)


if __name__ == '__main__':
    resolve()