Buggy python submission (verdict: Runtime Error):
### 素因数分解する。
from collections import defaultdict

def factorize(n):
    """

    """
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i==0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in LCM:
                LCM[i] = max(LCM[i], cnt)
            else:
                LCM[i] = cnt
    if tmp != 1:
        LCM[tmp] = max(LCM[tmp], 1)
    if not LCM:
        LCM[N] = max(LCM[N], 1)

def inv(n, p):
    return pow(n, p-2, p)

LCM = defaultdict()
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

for i in range(N):
    if A[i] != 1:
        factorize(A[i])

lcm = 1
for key, val in LCM.items():
    lcm *= pow(key, val, mod)
    lcm %= mod

inv_sum = 0
for i in range(N):
    inv_sum += inv(A[i], mod)
    inv_sum %= mod

print(lcm * inv_sum % mod)

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)%mod
        ans %= mod

    print(ans % mod)
main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

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

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


# Load data
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
# LCM: dict 最小公倍数の素因数分解
LCM = 1
for a in A:
    LCM = lcm(LCM, a)
# A2Factor: list A[i]の素因数分解
A2Factor = []

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

print(ans % mod)


Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, Counter
import sys
input = sys.stdin.readline
def main():
    # Load data
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    # LCM: dict 最小公倍数の素因数分解
    LCM = defaultdict(int)
    # A2Factor: list A[i]の素因数分解
    A2Factor = []
    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n**0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]
    PRIME_LIST = primes(max(A))
    def factorization(n):
        arr = []
        temp = n
        for i in PRIME_LIST:
            if temp%i==0:
                # cnt=0
                while temp%i==0:
                    # cnt+=1
                    temp //= i
                    arr.append(i)

        if temp!=1:
            # arr[temp] = 1
            arr.append(temp)

        if not arr:
            # arr[n] = 1
            arr.append(n)

        return arr

    for idx in range(N):
        arr = factorization(A[idx])
        arr = Counter(arr)
        for key, value in arr.items():
            LCM[key] = max(LCM[key], value)
        A2Factor.append(arr)
    ans = 0
    for i in range(N):
        tmp = 1
        for key, value in LCM.items():
            cnt = 0 if key not in A2Factor[i].keys() else A2Factor[i][key]
            tmp *= pow(key, value-cnt, p)
            tmp %= p
        ans += tmp % p
        ans %= p

    print(ans % p)

main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, Counter
import sys
input = sys.stdin.readline
def main():
    # Load data
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    # LCM: dict 最小公倍数の素因数分解
    LCM = defaultdict(int)
    # A2Factor: list A[i]の素因数分解
    A2Factor = []
    
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                # cnt=0
                while temp%i==0:
                    # cnt+=1
                    temp //= i
                    arr.append(i)

        if temp!=1:
            # arr[temp] = 1
            arr.append(temp)

        if not arr:
            # arr[n] = 1
            arr.append(n)

        return arr

    for idx in range(N):
        arr = factorization(A[idx])
        arr = Counter(arr)
        for key, value in arr.items():
            LCM[key] = max(LCM[key], value)
        A2Factor.append(arr)
    ans = 0
    for i in range(N):
        tmp = 1
        for key, value in LCM.items():
            cnt = 0 if key not in A2Factor[i].keys() else A2Factor[i][key]
            tmp *= pow(key, value-cnt, p)
            tmp %= p
        ans += tmp % p
        ans %= p

    print(ans % p)

main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, Counter
import sys
input = sys.stdin.readline
def main():
    # Load data
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    # LCM: dict 最小公倍数の素因数分解
    LCM = defaultdict(int)
    # A2Factor: list A[i]の素因数分解
    A2Factor = []
    
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                # cnt=0
                while temp%i==0:
                    # cnt+=1
                    temp //= i
                    arr.append(i)

        if temp!=1:
            # arr[temp] = 1
            arr.append(temp)

        if not arr:
            # arr[n] = 1
            arr.append(n)

        return arr

    for idx in range(N):
        arr = factorization(A[idx])
        arr = Counter(arr)
        for key, value in arr.items():
            LCM[key] = max(LCM[key], value)
        A2Factor.append(arr)
    ans = 0
    for i in range(N):
        tmp = 1
        for key, value in LCM.items():
            cnt = 0 if key not in A2Factor[i].keys() else A2Factor[i][key]
            tmp *= pow(key, value-cnt, p)
            tmp %= p
        ans += tmp % p
        ans %= p

    print(ans % p)

main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def main():
    # Load data
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    # LCM: dict 最小公倍数の素因数分解
    LCM = defaultdict(int)
    # A2Factor: list A[i]の素因数分解
    A2Factor = []
    
    def factorization(n):
        arr = defaultdict(int)
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr[i] = cnt

        if temp!=1:
            arr[temp] = 1

        if not arr:
            arr[n] = 1

        return arr

    for idx in range(N):
        arr = factorization(A[idx])
        for key, value in arr.items():
            LCM[key] = max(LCM[key], value)
        A2Factor.append(arr)
    ans = 0
    for i in range(N):
        tmp = 1
        for key, value in LCM.items():
            cnt = 0 if key not in A2Factor[i].keys() else A2Factor[i][key]
            tmp *= pow(key, value-cnt, p)
            tmp %= p
        ans += tmp % p
        ans %= p

    print(ans % p)

main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
from collections import defaultdict
def main():
    # Load data
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    # LCM: dict 最小公倍数の素因数分解
    LCM = defaultdict(int)
    # A2Factor: dict A[i]の素因数分解
    A2Factor = [defaultdict(int) for _ in range(N)]
    
    def factorization(n, idx):
        """
        素因数分解
        """
        temp = n
        flag = 0
        for i in range(2, int(sqrt(n))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)

    ans = 0
    for i in range(N):
        tmp = 1
        for key, value in LCM.items():
            cnt = 0 if key not in A2Factor[i].keys() else A2Factor[i][key]
            tmp *= pow(key, value-cnt, p)
            tmp %= p
        ans += tmp % p
        ans %= p

    print(ans % p)

main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Runtime Error):
from math import sqrt
def main():
    
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    MAX = max(A)
    CONST = int(sqrt(MAX)) + 1000
    LCM = {num: 0 for num in range(2, CONST)}
    A2Factor = [{num: 0 for num in range(2, CONST)} for _ in range(N)]
    for i in range(N):
        A2Factor[i][A[i]] = 0
        LCM[A[i]] = 0

    def factorization(n, idx):
        temp = n
        flag = 0
        for i in range(2, int(sqrt(n))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)
    

    ans = 0
    for i in range(N):
        ans_dict = dict()
        tmp = 1
        for num in range(2, CONST):
            ans_dict[num] = abs(LCM[num] - A2Factor[i][num])
        ans_dict[A[i]] = abs(LCM[A[i]] - A2Factor[i][A[i]])
        # print(ans_dict)
        for key, value in ans_dict.items():
            tmp *= pow(key, value, p)
            tmp %= p
        ans += tmp % p

    print(ans % p)
main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    MAX = max(A)

    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n**0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]
    PRIME_LIST = primes(MAX)
    LCM = {num: 0 for num in PRIME_LIST}
    A2Factor = [{num: 0 for num in PRIME_LIST} for _ in range(N)]

    def factorization(n, idx):
        temp = n
        flag = 0
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)

    ans = 0
    for i in range(N):
        ans_dict = {}
        tmp = 1
        for num in PRIME_LIST:
            ans_dict[num] = abs(LCM[num] - A2Factor[i][num])
        for key, value in ans_dict.items():
            tmp *= pow(key, value, p)
            tmp %= p
        ans += tmp%p
    print(ans % p)
main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    MAX = max(A)
    LCM = {num: 0 for num in range(2, MAX+1)}
    A2Factor = [{num: 0 for num in range(2, MAX+1)} for _ in range(N)]

    def factorization(n, idx):
        temp = n
        flag = 0
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)

    ans = 0
    for i in range(N):
        ans_dict = {}
        tmp = 1
        for num in range(2, MAX+1):
            ans_dict[num] = abs(LCM[num] - A2Factor[i][num])
        for key, value in ans_dict.items():
            tmp *= pow(key, value, p)
            tmp %= p
        ans += tmp%p
    print(ans % p)
main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    MAX = max(A)
    LCM = {num: 0 for num in range(2, MAX+1)}
    A2Factor = [{num: 0 for num in range(2, MAX+1)} for _ in range(N)]

    def factorization(n, idx):
        temp = n
        flag = 0
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)

    ans = 0
    for i in range(N):
        ans_dict = {}
        tmp = 1
        for num in range(2, MAX+1):
            ans_dict[num] = abs(LCM[num] - A2Factor[i][num])
        for key, value in ans_dict.items():
            tmp *= pow(key, value, p)
            tmp %= p
        ans += tmp%p
    print(ans % p)
if __name__ == "__main__":
    main()

Fixed submission:
from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()