Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
g = 0
lcm = 1
for x in a:
  g = gcd(lcm, x)
  lcm *= x // g
res = 0
for x in a:
  res += lcm // x
  res %= mod
print(res)

Fixed submission:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
class sieve:
  def __init__(self, n):
    self.n = n
    self.sv = [1] * (n + 1)
    self.sv[0] = 0
    self.sv[1] = 0
    for i in range(2, n + 1):
      if self.sv[i]:
        for j in range(i * 2, n + 1, i):
          self.sv[j] = 0
  def isprime(self, x):
    if x > self.n:
      return False
    return self.sv[x] == 1
  def factorize(self, x):
    res = []
    for i in range(2, self.n + 1):
      if self.sv[i]:
        while x % i == 0:
          x //= i
          res.append(i)
    if x != 1:
      res.append(x)
    return res
  def modgcd(self, a, mod):
    res = [float("inf")] * (self.n + 1)
    vis = set()
    f = self.factorize(a[0])
    for j in f:
      res[j] = f.count(j)
      vis.add(j)
    for i in range(1, len(a)):
      f = self.factorize(a[i])
      for j in vis:
        res[j] = min(f.count(j), res[j])
        vis.add(j)
    rres = 1
    for i in range(self.n + 1):
      if res[i] != float("inf"):
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
  def modlcm(self, a, mod):
    res = [0] * (self.n + 1)
    for i in range(len(a)):
      f = self.factorize(a[i])
      for j in f:
        res[j] = max(f.count(j), res[j])
    rres = 1
    for i in range(self.n + 1):
      if res[i] != 0:
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
sv = sieve(10 ** 6)
lcm = sv.modlcm(a, 10 ** 9 + 7)
res = 0
for x in a:
  res += lcm * pow(x, 10 ** 9 + 5, 10 ** 9 + 7)
res %= 10 ** 9 + 7
print(res)

Fixed submission:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
class sieve:
  def __init__(self, n):
    self.n = n
    self.sv = [1] * (n + 1)
    self.sv[0] = 0
    self.sv[1] = 0
    for i in range(2, n + 1):
      if self.sv[i]:
        for j in range(i * 2, n + 1, i):
          self.sv[j] = 0
  def isprime(self, x):
    if x > self.n:
      return False
    return self.sv[x] == 1
  def factorize(self, x):
    res = []
    for i in range(2, self.n + 1):
      if self.sv[i]:
        while x % i == 0:
          x //= i
          res.append(i)
    if x != 1:
      res.append(x)
    return res
  def modgcd(self, a, mod):
    res = [float("inf")] * (self.n + 1)
    vis = set()
    f = self.factorize(a[0])
    for j in f:
      res[j] = f.count(j)
      vis.add(j)
    for i in range(1, len(a)):
      f = self.factorize(a[i])
      for j in vis:
        res[j] = min(f.count(j), res[j])
        vis.add(j)
    rres = 1
    for i in range(self.n + 1):
      if res[i] != float("inf"):
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
  def modlcm(self, a, mod):
    res = [0] * (self.n + 1)
    for i in range(len(a)):
      f = self.factorize(a[i])
      for j in f:
        res[j] = max(f.count(j), res[j])
    rres = 1
    for i in range(self.n + 1):
      if res[i] != 0:
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
sv = sieve(10 ** 6)
lcm = sv.modlcm(a, 10 ** 9 + 7)
res = 0
for x in a:
  res += lcm * pow(x, 10 ** 9 + 5, 10 ** 9 + 7)
  res %= 10 ** 9 + 7
print(res)

Fixed submission:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
class sieve:
  def __init__(self, n):
    self.n = n
    self.sv = [1] * (n + 1)
    self.sv[0] = 0
    self.sv[1] = 0
    for i in range(2, n + 1):
      if self.sv[i]:
        for j in range(i * 2, n + 1, i):
          self.sv[j] = 0
  def isprime(self, x):
    if x > self.n:
      return False
    return self.sv[x] == 1
  def factorize(self, x):
    res = []
    for i in range(2, self.n + 1):
      if self.sv[i]:
        while x % i == 0:
          x //= i
          res.append(i)
    if x != 1:
      res.append(x)
    return res
  def modgcd(self, a, mod):
    res = [float("inf")] * (self.n + 1)
    vis = set()
    f = self.factorize(a[0])
    for j in f:
      res[j] = f.count(j)
      vis.add(j)
    for i in range(1, len(a)):
      f = self.factorize(a[i])
      for j in vis:
        res[j] = min(f.count(j), res[j])
        vis.add(j)
    rres = 1
    for i in range(self.n + 1):
      if res[i] != float("inf"):
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
  def modlcm(self, a, mod):
    res = [0] * (self.n + 1)
    for i in range(len(a)):
      f = self.factorize(a[i])
      for j in f:
        res[j] = max(f.count(j), res[j])
    rres = 1
    for i in range(self.n + 1):
      if res[i] != 0:
        rres *= pow(i, res[i], mod)
        rres %= mod
    return rres
sv = sieve(10 ** 3)
lcm = sv.modlcm(a, 10 ** 9 + 7)
res = 0
for x in a:
  res += lcm * pow(x, 10 ** 9 + 5, 10 ** 9 + 7)
  res %= 10 ** 9 + 7
print(res)

Fixed submission:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a: l = x * l // gcd(x, l)
for x in a:
  res += l // x
  res %= mod
print(res)

Fixed submission:
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
res = 0
for x in a:
  l = x * l // gcd(x, l)
l %= mod
for x in a:
  res += l * pow(x, mod - 2, mod)
  res %= mod
print(res)