Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7

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

ans=0
for i in range(n):
  ans=(ans+lcm//A[i])%mod
print(ans)


Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
import collections

P=collections.defaultdict(int)
PI=[collections.defaultdict(int) for _ in range(n)]
for i in range(n):
  a=A[i]
  for j in range(2,int(a**0.5)+1):
    while a%j==0:
      PI[i][j]+=1
      a//=j
  if a>1:
    PI[i][a]=1
  for p in PI[i].keys():
    P[p]=max(P[p],PI[i][p])
ans=0
for i in range(n):
  mul=1
  for p in P.keys():
    mul=(mul*pow(p,P[p]-PI[i][p],mod))%mod


  ans=(ans+mul)%mod
print(ans)

Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
import collections

P=collections.defaultdict(int)
PI=[collections.defaultdict(int) for _ in range(n)]
for i in range(n):
  a=A[i]
  for j in range(2,int(a**0.5)+1):
    while a%j==0:
      PI[i][j]+=1
      a//=j
  if a>1:
    PI[i][a]=1
  for p in PI[i].keys():
    P[p]=max(P[p],PI[i][p])
ans=0
for i in range(n):
  mul=1
  for p in P.keys():
    mul=(mul*pow(p,(P[p]-PI[i][p])))%mod


  ans=(ans+mul)%mod
print(ans)

Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**100000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]
for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])

ans=0
for i in range(n):
  ans=(ans+lcm//A[i])%mod
print(ans)


Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]
for i in range(1,n):
  lcm=lcm*A[i]//gcd(lcm,A[i])

ans=0
for i in range(n):
  ans=(ans+lcm//A[i])%mod
print(ans)


Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]
for i in range(1,n):
  lcm=lcm*A[i]//gcd(lcm,A[i])

ans=0
for i in range(n):
  ans=(ans+lcm//A[i])%mod
print(ans)


Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)