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

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

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

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        if max(lcm,x) % min(lcm,x) == 0:
            g = min(lcm,x)
        else:
            g = gcd(lcm,x)
        lcm = (lcm * x) // g
    ans = 0
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b
def modmul(a,b):
    return a * b % 1000000007
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],1000000007) for x in fac.items()]
    if len(f) > 0:
        lcm = reduce(modmul,f)
    else:
        lcm = 1
    for x in A:
        ans = (ans + (lcm * modinv(x,1000000007))) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b
def modmul(a,b):
    return a * b % 1000000007
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],1000000007) for x in fac.items()]
    if len(f) > 0:
        lcm = reduce(modmul,f)
    else:
        lcm = 1
    for x in A:
        ans = (ans + (lcm * modinv(x,1000000007))) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],1000000007) for x in fac.items()]
    if len(f) > 0:
        lcm = reduce(mul,f)
    else:
        lcm = 1
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],1000000007) for x in fac.items()]
    if len(f) > 0:
        lcm = reduce(mul,f)
    else:
        lcm = 1
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(x)
    ans = 0
    f = [pow(x[0],x[1],100000007) for x in fac.items()]
    lcm = reduce(mul,f)
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
from functools import reduce
from operator import mul

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    b = Counter(a)
    return b

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    fac = prime_factorize(A[0]) | prime_factorize(A[1])
    for x in A[2:]:
        fac |= prime_factorize(A[i])
    ans = 0
    f = [pow(x[0],x[1],100000007) for x in fac.items()]
    lcm = reduce(mul,f)
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    gcd = xgcd(A[0],A[1])
    lcm = (A[0]*A[1]) // gcd
    for x in A[2:]:
        if max(lcm,x) % min(lcm,x) == 0:
            gcd = min(lcm,x)
        else:
            gcd = xgcd(lcm,x)
        lcm = (lcm * x) // gcd
    ans = 0
    for x in A:
        ans = (ans + (lcm // x)) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    gcd = xgcd(A[0],A[1])
    lcm = (A[0]*A[1]) // gcd
    for x in A[2:]:
        if max(lcm,x) % min(lcm,x) == 0:
            gcd = min(lcm,x)
        else:
            gcd = xgcd(lcm,x)
        lcm = (lcm * x) // gcd
    ans = 0
    b = [lcm // x for x in A]
    for x in b:
        ans = (ans + x) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    gcd = xgcd(A[0],A[1])
    lcm = (A[0]*A[1]) // gcd
    for i in range(2,N):
        gcd = xgcd(lcm,A[i])
        lcm = (lcm * A[i]) // gcd
    ans = 0
    b = [lcm // x for x in A]
    for x in b:
        ans = (ans + x) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    gcd = xgcd(A[0],A[1])
    lcm = (A[0]*A[1]) // gcd
    for i in range(2,N):
        gcd = xgcd(lcm,A[i])
        lcm = (lcm * A[i]) // gcd
    ans = 0
    b = [lcm // x for x in A]
    for x in b:
        ans = (ans + x) % 1000000007
    print(ans)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    gcd = xgcd(A[0],A[1])
    lcm = (A[0] * A[1]) // gcd
    for i in range(2,N):
        gcd = xgcd(lcm,A[i])
        lcm = (lcm * A[i]) // gcd
    print(sum([lcm // x for x in A])%1000000007)

Fixed submission:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print('1')
else:
    g = gcd(A[0],A[1])
    lcm = (A[0]*A[1]) // g
    for x in A[2:]:
        lcm = (lcm * x) // gcd(lcm,x)
    print(sum((lcm//x) for x in A)%1000000007)