atcoder#ABC152E. [ABC152E] Flatten

[ABC152E] Flatten

Score : 500500 points

Problem Statement

Given are NN positive integers A1,...,ANA_1,...,A_N.

Consider positive integers B1,...,BNB_1, ..., B_N that satisfy the following condition.

Condition: For any i,ji, j such that 1i<jN1 \leq i < j \leq N, AiBi=AjBjA_i B_i = A_j B_j holds.

Find the minimum possible value of B1+...+BNB_1 + ... + B_N for such B1,...,BNB_1,...,B_N.

Since the answer can be enormous, print the sum modulo (109+710^9 +7).

Constraints

  • 1N1041 \leq N \leq 10^4
  • 1Ai1061 \leq A_i \leq 10^6
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 ...... ANA_N

Output

Print the minimum possible value of B1+...+BNB_1 + ... + B_N for B1,...,BNB_1,...,B_N that satisfy the condition, modulo (109+710^9 +7).

3
2 3 4
13

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

5
12 12 12 12 12
5

We can let all BiB_i be 11.

3
1000000 999999 999998
996989508

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