CA Loves GCD

Time Limit: 6000/3000 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

Description

CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too.
Now, there are $N$ different numbers. Each time, CA will select several numbers (at least one), and find the GCD of these numbers. In order to have fun, CA will try every selection. After that, she wants to know the sum of all GCDs.
If and only if there is a number exists in a selection, but does not exist in another one, we think these two selections are different from each other.

Input

First line contains $T$ denoting the number of testcases.
$T$ testcases follow. Each testcase contains a integer in the first time, denoting $N$, the number of the numbers CA have. The second line is $N$ numbers.
We guarantee that all numbers in the test are in the range [1,1000].
$1 \le T \le 50$

Output

$T$ lines, each line prints the sum of GCDs mod $100000007$.

Sample Input

2 2 2 4 3 1 2 3

Sample Output

8 10

Hint

wange2014

Source

BestCoder Round #78 (div.2)

提交代码