Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import sys

input = sys.stdin.readline

mp = 1000000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

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

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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

A_fact = [0] * N###Aの各要素の素因数分解
for i in range(N):
    A_fact[i] = prime_factorize(A[i])
#print(A_fact[0][0:12])

l_fact = A_fact[0][:]

for i in range(1,N):
    for j in range(1,mp):
        l_fact[j] = max(A_fact[i][j],l_fact[j])

B0_fact = [0] * mp


for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)
#print(A_fact[0][0:12])
#print(B0_fact[0:12])
#print(cal_mod(l_fact))
#print(ans)
#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

Fixed submission:
###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草

Buggy python submission (verdict: Runtime Error):
import fractions
import sys

input = sys.stdin.readline

mp = 1000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

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

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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

A_fact = [0] * N###Aの各要素の素因数分解
for i in range(N):
    A_fact[i] = prime_factorize(A[i])
#print(A_fact[0][0:12])

l_fact = A_fact[0][:]

for i in range(1,N):
    for j in range(1,mp):
        l_fact[j] = max(A_fact[i][j],l_fact[j])

B0_fact = [0] * mp


for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)
#print(A_fact[0][0:12])
#print(B0_fact[0:12])
#print(cal_mod(l_fact))
#print(ans)
#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

Fixed submission:
###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草

Buggy python submission (verdict: Runtime Error):
import fractions
import sys

input = sys.stdin.readline

mp = 1000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

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

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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


l = A[0]###A全体の最大公約数

for i in range(1,N):
    l = lcm(l,A[i])

B0_fact = [0] * mp
l_fact = prime_factorize(l)

A_fact = [0] * N
for i in range(N):
    A_fact[i] = prime_factorize(A[i])

for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)

#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

Fixed submission:
###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草

Buggy python submission (verdict: Runtime Error):
import fractions
import collections

mp = 1000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

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

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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


l = A[0]###A全体の最大公約数

for i in range(1,N):
    l = lcm(l,A[i])

B0_fact = [0] * mp
l_fact = prime_factorize(l)

A_fact = [0] * N
for i in range(N):
    A_fact[i] = prime_factorize(A[i])

for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)

#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

Fixed submission:
###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草

Buggy python submission (verdict: Runtime Error):
import fractions
import collections

mp = 1000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

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

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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


l = A[0]###A全体の最大公約数

for i in range(1,N):
    l = lcm(l,A[i])

B0_fact = [0] * mp
l_fact = prime_factorize(l)

A_fact = [0] * N
for i in range(N):
    A_fact[i] = prime_factorize(A[i])

for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)

#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

Fixed submission:
###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草