Problem:
Score : 500 points

Problem Statement

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).

Constraints

1 \leq N \leq 10^4

1 \leq A_i \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).

Sample Input 1

3
2 3 4

Sample Output 1

13

Let B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.

Sample Input 2

5
12 12 12 12 12

Sample Output 2

5

We can let all B_i be 1.

Sample Input 3

3
1000000 999999 999998

Sample Output 3

996989508

Print the sum modulo (10^9+7).

Solution in PyPy3 (2.4.0) (judge verdict: Accepted)

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
#mint
class ModInt:
    def __init__(self, x):
        self.x = x % mod
    
    def __str__(self):
        return str(self.x)
    
    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    __radd__ = __add__
        
    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __rsub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, mod-2,mod))
        else:
            return ModInt(self.x * pow(other, mod - 2, mod))
            
    def __rtruediv(self, other):
        if isinstance(other, self):
            return ModInt(other * pow(self.x, mod - 2, mod))
        else:
            return ModInt(other.x * pow(self.x, mod - 2, mod))
            

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, mod))
        else:
            return ModInt(pow(self.x, other, mod))
            

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, mod))
        else:
            return ModInt(pow(other, self.x, mod))


# 素因数分解
def prime_factorization(n):
    fact=[]
    fact=defaultdict(int)
    for i in range(2, int(sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            # fact.append(i)
            fact[i]+=1
            # print(n,i)
    if n!=1:
        fact[n]+=1
    return fact
def main():
    N=I()
    A=LI()

    lcm = defaultdict(int)
    for a in A:
        p = prime_factorization(a)
        for k in p.keys():
            lcm[k] = max(p[k],lcm[k])
    L = ModInt(1)
    for l,v in lcm.items():
        L *= l**v
    ans = ModInt(0)
    for a in A:
        ans += L/a
    print(ans)
    
if __name__ == '__main__':
    main()

# #
# # 　　  ⋀_⋀　 
# #　　  (･ω･)  
# # .／ Ｕ ∽ Ｕ＼
# #  │＊　合　＊│
# #  │＊　格　＊│ 
# #  │＊　祈　＊│ 
# #  │＊　願　＊│ 
# #  │＊　　　＊│ 
# #      ￣
# #
# import sys
# sys.setrecursionlimit(10**6)
# input=sys.stdin.readline
# # from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
# # from heapq import heappop, heappush, heappushpop
# # from collections import Counter,defaultdict,deque
# # from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
# # from bisect import bisect_left,bisect_right
# # from copy import deepcopy
# from fractions import gcd
# inf=float('inf')
# mod = 10**9+7
# def pprint(*A): 
#     for a in A:     print(*a,sep='\n')
# def INT_(n): return int(n)-1
# def MI(): return map(int,input().split())
# def MF(): return map(float, input().split())
# def MI_(): return map(INT_,input().split())
# def LI(): return list(MI())
# def LI_(): return [int(x) - 1 for x in input().split()]
# def LF(): return list(MF())
# def LIN(n:int): return [I() for _ in range(n)]
# def LLIN(n: int): return [LI() for _ in range(n)]
# def LLIN_(n: int): return [LI_() for _ in range(n)]
# def LLI(): return [list(map(int, l.split() )) for l in input()]
# def I(): return int(input())
# def F(): return float(input())
# def ST(): return input().replace('\n', '')
# #mint
# class ModInt:
#     def __init__(self, x):
#         self.x = x % mod
    
#     def __str__(self):
#         return str(self.x)
    
#     __repr__ = __str__

#     def __add__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(self.x + other.x)
#         else:
#             return ModInt(self.x + other)

#     __radd__ = __add__
        
#     def __sub__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(self.x - other.x)
#         else:
#             return ModInt(self.x - other)

#     def __rsub__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(other.x - self.x)
#         else:
#             return ModInt(other - self.x)

#     def __mul__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(self.x * other.x)
#         else:
#             return ModInt(self.x * other)

#     __rmul__ = __mul__

#     def __truediv__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(self.x * pow(other.x, mod-2,mod))
#         else:
#             return ModInt(self.x * pow(other, mod - 2, mod))
            
#     def __rtruediv(self, other):
#         if isinstance(other, self):
#             return ModInt(other * pow(self.x, mod - 2, mod))
#         else:
#             return ModInt(other.x * pow(self.x, mod - 2, mod))
            

#     def __pow__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(pow(self.x, other.x, mod))
#         else:
#             return ModInt(pow(self.x, other, mod))
            

#     def __rpow__(self, other):
#         if isinstance(other, ModInt):
#             return ModInt(pow(other.x, self.x, mod))
#         else:
#             return ModInt(pow(other, self.x, mod))

# def main():
#     N=I()
#     A=LI()
#     l = 1
#     for a in A:
#         l *= a//gcd(l,a)
#     ans = 0
#     l = ModInt(l)
#     for a in A:
#         ans += l/a
#     print(ans)
# if __name__ == '__main__':
#     main()