The minimum sum

4

1 votes
Number Theory, Algorithms, GCD, Math, Greedy algorithm
Problem

You are given an array A containing N positive integers. Consider an array B that also contains N positive integers and it satisfies the following condition: 

  • For all i, consider j such that 1i<jN,AiBi=AjBj holds correct. 

Find the minimum possible value of B1+B2+...+BN for array B. Since the answer can be large, print the sum modulo 1000000007.

Input format

  • The first line contains an integer T denoting the number of test cases.
  • The first line of each test case contains a single integer N denoting the size of the array A.
  • The second line of each test case contains N space-separated integers denoting the array A.

Output format

For each test case, print the sum modulo 1000000007 in a new line.

Constraints

1T100001N2000001Ai1000000

The sum of N over T test cases does not exceed 200000.

Sample Input
2
4
1 2 3 4
5
2 4 6 8 10
Sample Output
25
137
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

For the first test case, the array B=[12,6,4,3]. Thus, the minimum sum possible is 25.

For the second test case, the array B=[60,30,20,15,12]. Thus, the minimum sum possible is 137.

Editor Image

?