Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
p = []
for a in A:
    tt = prime_factorize(a)
    fa = fa | tt
    p.append(tt)

kb = 1
for k, v in fa.items():
    kb *= pow(k, v)

mod = 10**9+7
s = sum(pow(a, mod-2, mod) for a in A)
print(s*kb%mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
p = []
for a in A:
    tt = prime_factorize(a)
    fa = fa | tt
    p.append(tt)

ans = 0
mod = 10**9+7
for i in range(n):
    t = 1
    fb = fa - p[i]
    for k, v in fb.items():
        t *= pow(k, v, mod)
        t %= mod
    ans += t % mod
    ans %= mod
print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
p = []
for a in A:
    tt = prime_factorize(a)
    fa = fa | tt
    p.append(tt)

ans = 0
mod = 10**9+7
for i in range(n):
    t = 1
    fb = fa - p[i]
    for k, v in fb.items():
        t *= pow(k, v, mod)
    ans += t % mod
    ans %= mod
print(ans % mod)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
ans = a[0]
for i in range(1, n):
    ans = ans*a[i]//gcd(ans, a[i])
# s = sum(pow(x, mod-2, mod) for x in a)
s = sum((1/x)%mod for x in a)
print(int(s*ans%mod))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
ans = a[0]
for i in range(1, n):
    ans = ans*a[i]//gcd(ans, a[i])
# s = sum(pow(x, mod-2, mod) for x in a)
s = sum(1/x for x in a)
print(int(s*ans%mod))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
p = []
for a in A:
    tt = prime_factorize(a)
    fa = fa | tt
    p.append(tt)

ans = 0
mod = 10**9+7
for i in range(n):
    t = 1
    fb = fa - p[i]
    for k, v in fb.items():
        t *= pow(k, v, mod)
    ans += t % mod
print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
for a in A:
    fa = fa | prime_factorize(a)

ans = 0
mod = 10**9+7
for a in A:
    t = 1
    fb = fa - prime_factorize(a)
    for k, v in fb.items():
        t *= pow(k, v, mod)
    ans += t % mod
print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
for a in A:
    fa = fa | prime_factorize(a)

ans = 0
mod = 10**9+7
for a in A:
    t = 1
    fb = fa - prime_factorize(a)
    for k, v in fb.items():
        t *= (k**v % mod)
    ans += t % mod
print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))