Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = defaultdict(int)
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  b = 1
  for k,v in lcm.items():
    b *= k**(v-i[k])
    b %= mod
  ans += b
ans %= mod
print(ans)


Fixed submission:
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = defaultdict(int)
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  b = 1
  for k,v in lcm.items():
    b *= pow(k,v-i[k])
    b %= mod
  ans += b
ans %= mod
print(ans)

Fixed submission:
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = dict()
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  bi = copy.copy(lcm)
  for k,v in i.items():
    bi[k] -= v
  b = 1
  for k,v in bi.items():
    b *= k ** v
    b %= mod
  ans += b
ans %= mod
print(ans)

Fixed submission:
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)



Fixed submission:
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = sorted(list(map(int, input().split())))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)

Fixed submission:
import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

n = input()
a = list(map(int, input().split()))

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)