Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(a,b):
  return a * b // gcd(a,b)
 
n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)
 
tot = 0
for i in range(n):
  tot += alcm // av[i]
 
print(tot % 1000000007)

Fixed submission:
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(a,b):
  return a * b // gcd(a,b)
 
n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)
 
tot = 0
for i in range(n):
  tot += alcm // av[i]
 
print(tot % 1000000007)

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


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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

# print(lcm(12, 8))
# print(lcm(20, 6))
# print(lcm(2, 2))
# print(lcm(100, 200))
# print(lcm(100, 240))


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split(' ')]

    cur = 1
    for ai in a:
        cur = lcm(cur, ai)

    ans = 0
    for ai in a:
        ans += cur // ai
        ans %= 10 ** 9 + 7

    print(ans)

main()


Fixed submission:
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(a,b):
  return a * b // gcd(a,b)
 
n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)
 
tot = 0
for i in range(n):
  tot += alcm // av[i]
 
print(tot % 1000000007)

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


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split(' ')]

    def do_it(num):
        if num == 1:
            return {}
        cur = num
        dic = defaultdict(int)

        while cur % 2 == 0:
            cur //= 2
            dic[2] += 1

        i = 3
        while i * i <= num:
            while cur % i == 0:
                dic[i] += 1
                cur //= i
            i += 1
        if cur != 1:
            dic[cur] += 1
        return dic

    d = defaultdict(int)
    d_list = []
    for ai in a:
        di = do_it(ai)
        d_list.append(di)
        keys = di.keys()
        for key in keys:
            d[key] = max(d[key], di[key])

    ans = 0
    for i in range(n):
        cur = 1
        keys = d.keys()
        d_i = d_list[i]
        for key in keys:
            diff = d[key] - d_i[key]
            for j in range(diff):
                cur *= key
                cur %= 10 ** 9 + 7
        ans += cur
        ans %= 10 ** 9 + 7
    print(ans)


main()


Fixed submission:
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(a,b):
  return a * b // gcd(a,b)
 
n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)
 
tot = 0
for i in range(n):
  tot += alcm // av[i]
 
print(tot % 1000000007)

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


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split(' ')]

    def do_it(num):
        if num == 1:
            return {}
        cur = num
        dic = defaultdict(int)
        for i in range(2, num+1):
            if cur == 1:
                break
            while cur % i == 0:
                dic[i] += 1
                cur //= i
        return dic

    d = defaultdict(int)
    d_list = []
    for ai in a:
        di = do_it(ai)
        d_list.append(di)
        keys = di.keys()
        for key in keys:
            d[key] = max(d[key], di[key])

    ans = 0
    for i in range(n):
        cur = 1
        keys = d.keys()
        d_i = d_list[i]
        for key in keys:
            diff = d[key] - d_i[key]
            for j in range(diff):
                cur *= key
                cur %= 10 ** 9 + 7
        ans += cur
        ans %= 10 ** 9 + 7
    print(ans)


main()


Fixed submission:
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(a,b):
  return a * b // gcd(a,b)
 
n = int(input())
av = list(map(int, input().split(' ')))
alcm = 1
for i in av:
  alcm = lcm(alcm, i)
 
tot = 0
for i in range(n):
  tot += alcm // av[i]
 
print(tot % 1000000007)