Buggy python submission (verdict: Runtime Error):
#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, nod-2, mod)
    ans %= mod
print(ans % mod)

Fixed submission:
#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, mod-2, mod)
    ans %= mod
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

import fractions
from functools import reduce

from copy import deepcopy

# def lcm(x, y):
#     return (x * y) // fractions.gcd(x, y)

big = 1000000007

def lcm(primes, num):
    facto = factorization(num)
    for key in facto:
        if key in primes:
            primes[key] = max(primes[key], facto[key])
        else:
            primes[key] = facto[key]
    return primes
        
def devide_facto(devided, deviding):
    devided = deepcopy(devided)
    for key in deviding:
        devided[key] -= deviding[key]
    return devided

def prod_facto(facto):
    prodv = 1
    for key in facto:
        if facto[key] == 0:
            continue
        prodv = prodv * key ** facto[key]
        prodv %= big
    return prodv
    
    
def factorization(num):
    i = 2
    facto = {}
    while i <= num ** (0.5):
        if num % i == 0:
            if i in facto.keys():
                facto[i] += 1
            else:
                facto[i] = 1
            num //= i
            continue
        i += 1
    if num in facto.keys():
        facto[num] += 1
    else:
        facto[num] = 1
    return facto
    

n = int(input())
a = list(map(int, input().split(' ')))
primes = {}
for num in a:
    primes = lcm(primes, num)

sumv = 0        
for num in a:
    facto_num = factorization(num)
    facto_devided = devide_facto(primes, facto_num)
    
    sumv += prod_facto(facto_devided)
    sumv %= big
    
print(sumv)


Fixed submission:
#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, mod-2, mod)
    ans %= mod
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = int(input())
a = list(map(int, input().split(' ')))

lcmv = 1
b_bar = []
for num in a:
    lcmv = lcm(num, lcmv)

ans = 0
for num in a:
    if num > lcmv:
        lcmv += 1000000007
    ans += lcmv // num
    ans %= 1000000007
print(ans)

Fixed submission:
#coding:utf-8

from fractions import gcd
n = int(input())
a = list(map(int, input().split(' ')))

mod = 10 ** 9 + 7

#最小公倍数を取得
g = a[0]
for num in a[1:]:
    g = g * num // gcd(num, g)

ans = 0
#計算後なのでmodオッケー
l = g % mod
for num in a:
    ans += l * pow(num, mod-2, mod)
    ans %= mod
print(ans % mod)