PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000082. Làm phẳng dãy bằng bội số (Flatten)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Làm phẳng dãy bằng bội số (Flatten)

Flatten

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN positive integers A1,…,ANA_1,\ldots,A_N, choose positive integers B1,…,BNB_1,\ldots,B_N such that every product AiBiA_iB_i has the same value. Find the smallest possible sum B1+⋯+BNB_1+\cdots+B_N, and print it modulo 109+710^9+7.

Input

The first line contains NN. The next line contains NN integers A1,…,ANA_1,\ldots,A_N.

Output

Print the minimum sum modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤N≤81\le N\le8, 1≤Ai≤301\le A_i\le30.

  • Subtask 2 (30 points): 1≤N≤3001\le N\le300, 1≤Ai≤1041\le A_i\le10^4.

  • Subtask 3 (50 points): 1≤N≤1041\le N\le10^4, 1≤Ai≤1061\le A_i\le10^6.

Examples

Input

3
2 3 4

Output

13

Explanation

Choose B=(6,4,3)B=(6,4,3). Then 2⋅6=3⋅4=4⋅3=122\cdot6=3\cdot4=4\cdot3=12 and the sum is 6+4+3=136+4+3=13. The common product 1212 is the smallest positive multiple of 2,3,42,3,4, hence the sum cannot be smaller.