Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
l[1]=1
for a in A:
  if a==1:
    continue
  x=0
  while a%2==0:
    a//=2
    x+=1

  l[2]=max(l[2],x)
  
  f = 3
  while f**2<=a:
    x = 0
    while a%f==0:
      a//=f
      x+=1
    l[f]=max(l[f],x)
    f+=2
    
  if a!=1:
    l[a]=max(l[a],1)
    
b = 1
for i,x in enumerate(l):
  b*=pow(i,x,mod)
  b%=mod
  
ans = 0
for a in A:
  ans+=(b*pow(a,mod-2,mod))%mod
  ans%=mod
  
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
for a in A:
  x=0
  while a%2==0:
    a//=2
    x+=1
    
  l[2]=max(l[2],x)
  
  f = 3
  while f**2<=a:
    x = 0
    while a%f==0:
      a//=f
      x+=1
    l[f]=max(l[f],x)
    f+=2
    
  if a!=1:
    l[a]=max(l[a],1)
    
b = 1
for i,x in enumerate(l):
  b*=pow(i,x,mod)
  b%=mod
  
ans = 0
for a in A:
  ans+=(b*pow(a,mod-2,mod))%mod
  ans%=mod
  
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
for a in A:
  x=0
  while a%2==0:
    a//=2
    x+=1
    
  l[2]=max(l[2],x)
  
  f = 3
  while f**2<=a:
    x = 0
    while a%f==0:
      a//=f
      x+=1
    l[f]=max(l[f],x)
    f+=2
    
  if a!=1:
    l[a]=max(l[a],1)
    
b = 1
for i,x in enumerate(l):
  b*=pow(i,x,mod)
  b%=mod
  
ans = 0
for a in A:
  ans+=(b*pow(a,mod-2,mod))%mod
  ans%=mod
  
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += (g//a)%mod
  ans %= mod
  
print(ans%mod)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)