Problem: Given are N positive integers A_1,...,A_N.  Consider positive integers B_1, ..., B_N that satisfy the following condition.  Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.  Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.  Since the answer can be enormous, print the sum modulo (10^9 +7).

Submission attempts (in order):

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

from fractions import gcd
from functools import reduce

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

L = reduce(lcm, A)

B = [None] * N

for i in range(N):
  B[i] = (L // A[i]) % mod

print(sum(B) % mod)


import sys
input = sys.stdin.readline

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

from fractions import gcd
from functools import reduce

L = A[0]
for i in range(1,N):
  L=(L*A[i])//gcd(L,A[i])

ans = 0

for i in range(N):
  ans += (L // A[i]) % mod

print(ans % mod)



def main():
  import sys
  input = sys.stdin.readline

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

  from fractions import gcd
  from functools import reduce

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

  L = reduce(lcm, A)

  B = [None] * N

  for i in range(N):
    B[i] = (L // A[i]) % mod

  print(sum(B) % mod)

if __name__ == '__main__':
    main()


def main():
  import sys
  input = sys.stdin.readline

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

  from fractions import gcd
  from functools import reduce

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

  L = reduce(lcm, T)

  ans = 0

  for i in range(N):
    ans += (L // A[i]) % mod

  print(ans % mod)

if __name__ == '__main__':
    main()


def main():
  import sys
  input = sys.stdin.readline

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

  from fractions import gcd
  from functools import reduce

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

  L = reduce(lcm, A)

  ans = 0

  for i in range(N):
    ans += (L // A[i]) % mod

  print(ans % mod)

if __name__ == '__main__':
    main()


def main():
  import sys
  input = sys.stdin.readline

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

  from fractions import gcd
  from functools import reduce

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

  L = reduce(lcm, T)

  B = [None] * N

  for i in range(N):
    B[i] = (L // A[i]) % mod

  print(sum(B) % mod)

if __name__ == '__main__':
    main()




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

def inverse(a): 
  return pow(a, mod-2, mod)

def eratosthenes(n): 
    A = [0] * n
    A[0], A[1] = -1, -1
    for i in range(2, n):
      if A[i] == 0:
        j = i
        while j < n:
          A[j] = i
          j += i
    return A

E = eratosthenes(10**6+5)
l = {}

for a in A:
  now = a
  f = [] 

  while now > 1:
    f.append(E[now])
    now //= E[now]

  chk = 0 

  for p in f:
    if chk == p: 
      continue
    chk = p
    if p in l.keys(): 
      l[p] = max(l[p], f.count(p))
    else: 
      l[p] = f.count(p)
 
lcm = 1
for k in l:
  for i in range(l[k]):
      lcm= lcm * k % mod

s = 0
for i in range(N):
    s += lcm * inverse(A[i])
    s %= mod
print(s)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Accepted