Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

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

def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(n**0.5//1)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr==[]:
        arr[n] = 1

    return arr

a_fac = []
lcm_fac = dict()
for i in range(n):
    tem = factorization(a[i])
    a_fac.append(tem)
    for fac in tem.keys():
        if fac in lcm_fac.keys():
            lcm_fac[fac] = max(tem[fac], lcm_fac[fac])
        else:
            lcm_fac[fac] = tem[fac]


ans = 0
for i in range(n):
    tem = 1
    for j in lcm_fac.keys():
        if j in a_fac[i].keys():
            tem *= j ** (lcm_fac[j] - a_fac[i][j])
        else:
            tem *= j ** lcm_fac[j]
    ans += tem

print(ans % (10**9+7))






Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

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

def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(n**0.5//1)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr==[]:
        arr[n] = 1

    return arr

a_fac = []
lcm_fac = dict()
for i in range(n):
    tem = factorization(a[i])
    a_fac.append(tem)
    for fac in tem.keys():
        if fac in lcm_fac.keys():
            lcm_fac[fac] = max(tem[fac], lcm_fac[fac])
        else:
            lcm_fac[fac] = tem[fac]


ans = 0
for i in range(n):
    tem = 1
    for j in lcm_fac.keys():
        if j in a_fac[i].keys():
            tem *= j ** (lcm_fac[j] - a_fac[i][j])
        else:
            tem *= j ** lcm_fac[j]
    ans += tem

print(ans % (10**9+7))






Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

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

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm//a[i]

print(sum(b) % (10**9+7))





Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

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

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm//a[i]

print(sum(b) % (10**9+7))





Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

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

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm//a[i]

print(sum(b) % (10**9+7))




Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
import fractions

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm/a[i]

print(int(sum(b)) % (10**9+7))




Fixed submission:
n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))