Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys
input = sys.stdin.readline

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f


def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    C = defaultdict(int)
    for a in A:
        tmp = fctr1(a)
        for i, j in tmp:
            C[i] = max(C[i],j)

    D = 1
    for i, j in C.items():
        D *= i ** j

    ans = 0
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return x // gcd(x, y) * y

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return x // gcd(x, y) * y

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for i in range(N):
        ans += D // A[i]
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return x // gcd(x, y) * y

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()