Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B = a * B // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

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


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def l(a, b):
    return a * b // g(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B = l(a, B)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def l(a, b):
    return a * b // g(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B = l(a, B)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    M = int(N ** 0.5) + 1
    F = [False, False] + [True] * M
    for n in range(2, M):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P
 

def ps(a, P, K):
    d = {}
    for p in P:
        c = 0
        while a % p == 0:
            c += 1
            a //= p
        d[p] = c

        if a == 1:
            break
    
    if a != 1:
        d[a] = 1
        K.add(a)
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))
    K = set()

    DA = [ps(a, P, K) for a in A]
    P.extend(list(K))

    D = {}
    res = 0
    for d in DA:
        b = 1
        for i in P:
            v = d.setdefault(i, 0)
            r = D.setdefault(i, 0)
            if v > r:
                D[i] = v
                res = res * pow(i, v - r, mod) % mod
            else:
                b = b * pow(i, r - v, mod) % mod
        
        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    M = int(N ** 0.5) + 1
    F = [False, False] + [True] * M
    for n in range(2, M):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P
 

def ps(a, P, K):
    d = {}
    for p in P:
        c = 0
        while a % p == 0:
            c += 1
            a //= p
        d[p] = c

        if a == 1:
            break
    
    if a != 1:
        d[a] = 1
        K.add(a)
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))
    K = set()

    DA = [ps(a, P, K) for a in A]
    P.extend(list(K))

    D = {}
    res = 0
    for d in DA:
        b = 1
        for i in P:
            v = d.setdefault(i, 0)
            r = D.setdefault(i, 0)
            if v > r:
                D[i] = v
                res = res * (i ** (v - r)) % mod
            else:
                b = b * (i ** (r - v)) % mod
        
        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    M = int(N ** 0.5) + 10
    F = [False, False] + [True] * M
    for n in range(2, M):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P
 

def ps(a, P):
    d = {}
    for p in P:
        while a % p == 0:
            d[p] = d.setdefault(p, 0) + 1
            a //= p
        
        if a == 1:
            break
    
    if a != 1:
        d[a] = d.setdefault(a, 0) + 1
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))
    DA = [ps(a, P) for a in A]
    keys = set()
    for d in DA:
        keys.update(d.keys())

    D = {}
    res = 0
    for d in DA:
        b = 1
        for i in keys:
            v = d.setdefault(i, 0)
            r = D.setdefault(i, 0)
            if v > r:
                D[i] = v
                res = res * (i ** (v - r)) % mod
            else:
                b = b * (i ** (r - v)) % mod
        
        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    M = int(N ** 0.5) + 10
    F = [False, False] + [True] * M
    for n in range(2, M):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P
 

def ps(a, P):
    d = {}
    for p in P:
        while a % p == 0:
            d[p] = d.setdefault(p, 0) + 1
            a //= p
        
        if a == 1:
            break
    
    if a != 1:
        d[a] = d.setdefault(a, 0) + 1
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))
    DA = [ps(a, P) for a in A]
    
    D = {}
    for d in DA:
        for i, v in d.items():
            D[i] = max(D.setdefault(i, 0), v)

    res = 0
    for d in DA:
        b = 1
        for i, v in D.items():
            b = b * (i ** max(0, v - d.setdefault(i, 0))) % mod

        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()


Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def ps(a):
    d = {}
    for n in range(2, a + 1):
        while a % n == 0:
            d[n] = d.setdefault(n, 0) + 1
            a //= n
        
        if a == 1:
            break
    return d


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    DA = [ps(a) for a in A]
    
    D = {}
    for d in DA:
        for i, v in d.items():
            D[i] = max(D.setdefault(i, 0), v)

    res = 0
    for d in DA:
        b = 1
        for i, v in D.items():
            b = b * (i ** max(0, v - d.setdefault(i, 0))) % mod

        res = (res + b) % mod

    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def Prim(N):
    P = []
    F = [False, False] + [True] * (N + 1)
    for n in range(2, N + 1):
        if not F[n]:
            continue
        P.append(n)
        for i in range(n, len(F), n):
            F[i] = False
    
    return P


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    P = Prim(max(A))

    l = 1
    res = 0
    for a in A:
        if l % a == 0:
            res = (res + l // a) % mod
            continue
        
        if a in P:
            l2 = l * a
        else:
            l2 = gm(a, l)
        res = (res * l2 // l) % mod
        res = (res + l2 // a) % mod
        l = l2
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a // lm(a, b) * b


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    l = 1
    res = 0
    for a in A:
        if l % a == 0:
            res = (res + l // a) % mod
        else:
            l2 = gm(a, l)
            res = (res * l2 // l) % mod
            res = (res + l2 // a) % mod
            l = l2
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    A.sort()

    l = 1
    res = 0
    for a in A:
        if l % a == 0:
            res = (res + l // a) % mod
        else:
            l2 = gm(a, l)
            res = (res * l2 // l) % mod
            res = (res + l2 // a) % mod
            l = l2
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()
    A.sort()

    l = 1
    res = 0
    for a in A:
        l2 = gm(a, l)
        res = (res * l2 // l) % mod
        res = (res + l2 // a) % mod
        l = l2
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    l = 1
    res = 0
    for i, a in enumerate(A):
        l2 = gm(l, a)
        res = (res * l2 // l) % mod
        res = (res + l2 // a) % mod
        l = l2
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    l = 1
    for a in A:
        l = gm(l, a)

    res = 0
    for a in A:
        res = (res + l // a) % mod
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def lm(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def gm(a, b):
    return a * b // lm(a, b)


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    l = 1
    for a in A:
        l = gm(l, a)

    res = 0
    for a in A:
        res = (res + l // a) % mod
    print(res)


if __name__ == "__main__":
    main()



Fixed submission:
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def g(a, b):
    if a > b:
        a, b = b, a
    while b % a:
        a, b = b % a, a
    return a


def main():
    mod = 10 ** 9 + 7
    N = int(input())
    A = read_list()

    B = 1
    for a in A:
        B *= a // g(B, a)
    
    print(sum(B // a for a in A) % mod)


if __name__ == "__main__":
    main()