Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(input().split()))
s=1
for a in A:
    s=lcm(s,i)
ans=0
for a in A:
    ans+=s//i
print(ans%(10**9+7))

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
D=[]
def factorization(N):
   i=2
   res={}
   while i*i<=N:
       if N%i!=0:
           i+=1
           continue
       res[i]=0
       while N%i==0:
           res[i]+=1
           N//=i
       i+=1
   if N!=1:
       res[N]=1
   return res

G={}
for a in A:
    b=factorization(a)
    D.append(b)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
cnt=0
for i in range(len(A)):
    x=1
    b=D[i]
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
        x%=P
    ans+=x
    ans%=P
print(ans)

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
D=[]
def factorization(N):
   i=2
   res={}
   while i*i<=N:
       if N%i!=0:
           i+=1
           continue
       res[i]=0
       while N%i==0:
           res[i]+=1
           N//=i
       i+=1
   if N!=1:
       res[N]=1
   return res

G={}
for a in A:
    b=factorization(a)
    D.append(b)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
cnt=0
for i in range(len(A)):
    x=1
    b=D[i]
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
        x%=P
    ans+=x
    ans%=P
print(ans)

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
D=[]
def factorization(N):
    temp={}
    while True:
        divided=False
        for i in range(2, int(N**0.5)+1):
            if N%i==0:
                if i in temp:
                    temp[i]+=1
                else:
                    temp[i]=1
                N=N//i
                divided=True
                break
        if not divided:
            if N in temp:
                temp[N]+=1
            else:
                temp[N]=1
            break
    return temp
G={}
for a in A:
    b=factorization(a)
    D.append(b)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
cnt=0
for i in range(len(A)):
    x=1
    b=D[i]
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
        x%=P
    ans+=x
    ans%=P
print(ans)

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
D=[]
def factorization(N):
    temp={}
    while True:
        divided=False
        for i in range(2, int(N**0.5)+1):
            if N%i==0:
                if i in temp:
                    temp[i]+=1
                else:
                    temp[i]=1
                N=N//i
                divided=True
                break
        if not divided:
            temp[1]=1
            if N in temp:
                temp[N]+=1
            else:
                temp[N]=1
            break
    return temp
G={}
for a in A:
    b=factorization(a)
    D.append(b)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
for i in range(len(A)):
    x=1
    b=D[i]
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
    ans+=x
    ans%=P
print(ans)

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
def factorization(N):
    temp={}
    while True:
        divided=False
        for i in range(2, int(N**0.5)+1):
            if N%i==0:
                if i in temp:
                    temp[i]+=1
                else:
                    temp[i]=1
                N=N//i
                divided=True
                break
        if not divided:
            temp[1]=1
            if N in temp:
                temp[N]+=1
            else:
                temp[N]=1
            break
    return temp
G={}
for a in A:
    b=factorization(a)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
for a in A:
    x=1
    b=factorization(a)
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
    ans+=x
    ans%=P
print(ans)

Fixed submission:
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))