Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n=int(input())
a = list(map(int, input().split()))
memo = defaultdict(int)
x = []
for y in a:
    i = y
    xx = defaultdict(int)
    c = 0
    while i%2==0:
        c += 1
        i //= 2
    memo[2] = max(memo[2], c)
    xx[2]=c
    for j in range(3, int(i**.5)+2, 2):
        c=0
        while i%j==0:
            c += 1
            i //= j
        memo[j] = max(memo[j], c)
        xx[j] = c
    if i!=1:
        xx[i]=1
        memo[i] = max(memo[i], 1)
    x.append(xx)
mod = 10**9+7
result = 0
for i in range(n):
    num = 1
    for s, t in memo.items():
        num *= pow(s, t-x[i][s])
    result = (result+num)%mod

print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n=int(input())
a = list(map(int, input().split()))
memo = defaultdict(int)
x = []
for y in a:
    i = y
    xx = defaultdict(int)
    c = 0
    while i%2==0:
        c += 1
        i //= 2
    memo[2] = max(memo[2], c)
    xx[2]=c
    for j in range(3, int(i**.5)+2, 2):
        c=0
        while i%j==0:
            c += 1
            i //= j
        memo[j] = max(memo[j], c)
        xx[j] = c
    if i!=1:
        xx[i]=1
        memo[i] = max(memo[i], 1)
    x.append(xx)
mod = 10**9+7
result = 0
for i in range(n):
    num = 1
    for s, t in memo.items():
        num *= pow(s, t-x[i][s])
    result = (result+num)%mod

print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int, input().split()))
memo = {2:0}
x = []
for y in a:
    i = y
    xx = {}
    c = 0
    while i%2==0:
        c += 1
        i //= 2
    memo[2] = max(memo[2], c)
    xx[2]=c
    for j in range(3, int(i**.5)+2, 2):
        if i%j==0:
            c=0
            while i%j==0:
                c += 1
                i //= j
            if j in memo:
                memo[j] = max(memo[j], c)
            else:
                memo[j] = c
            xx[j] = c
    if i!=1:
        xx[i]=1
        if i in memo:
            memo[i] = max(memo[i], 1)
        else:
            memo[i] = 1
    x.append(xx)
mod = 10**9+7
result = 0
for i in range(n):
    num = 1
    for s, t in memo.items():
        if s in x[i]:
            num *= pow(s, t-x[i][s])
        else:
            num *= pow(s,t)
    if result+num >= mod:
        result = (result+num)%mod
    else:
        result += num
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int, input().split()))
memo = {}
x = []
for i in a:
    xx = {}
    for j in range(2, int(i**.5)+2):
        if i%j==0:
            c=0
            while i%j==0:
                c += 1
                i //= j
            if j in memo:
                memo[j] = max(memo[j], c)
            else:
                memo[j] = c
            xx[j] = c
    if i!=1:
        xx[i]=1
        if i in memo:
            memo[i] = max(memo[i], 1)
        else:
            memo[i] = 1
    x.append(xx)
mod = 10**9+7
result = 0
for i in range(n):
    num = 1
    for s, t in memo.items():
        if s in x[i]:
            num *= pow(s, t-x[i][s])
        else:
            num *= pow(s,t)
    if result+num >= mod:
        result = (result+num)%mod
    else:
        result += num
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int, input().split()))
memo = {}
x = []
for i in a:
    xx = {}
    for j in range(2, int(i**.5)+2):
        if i%j==0:
            c=0
            while i%j==0:
                c += 1
                i //= j
            if j in memo:
                memo[j] = max(memo[j], c)
            else:
                memo[j] = c
            xx[j] = c
    if i!=1:
        xx[i]=1
        if i in memo:
            memo[i] = max(memo[i], 1)
        else:
            memo[i] = 1
    x.append(xx)
mod = 10**9+7
result = 0
for i in range(n):
    num = 1
    for s, t in memo.items():
        if s in x[i]:
            num *= pow(s, t-x[i][s])
        else:
            num *= pow(s,t)
    if result+num >= mod:
        result = (result+num)%mod
    else:
        result += num
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9 +7
n = int(input())
a = list(map(int, input().split()))
r = a[0]
for i in range(1, n):
    r = r*a[i]//gcd(r, a[i])
result = 0
for i in a:
    result += (r//i)%mod
    result %= mod
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9 +7
n = int(input())
a = list(map(int, input().split()))
r = a[0]
for i in range(1, n):
    r = r*a[i]//gcd(r, a[i])
result = 0
for i in a:
    result = (result+r//i)%mod
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9 +7
n = int(input())
a = list(map(int, input().split()))
r = a[0]
for i in range(1, n):
    r = r*a[i]//gcd(r, a[i])
result = 0
for i in a:
    result = (result+r//i)%mod
print(result)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

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

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    for j in range(2, int(i**.5)+1):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)