Sum of GCD#6941

Sum of GCD

1 saniye
128 megabayt
Kolay

For the given positive integers a_1, a_2, ..., a_n, find the sum of the GCD (greatest common divisor) of all possible pairs of these numbers.

\sum_{\mathclap{1 \le i < j\le n}} GCD(a_i,a_j)

Giriş

The first line contains the number of test cases t~(1 < t < 100). Each test consists of one line containing the number n~(1 < n < 100), followed by positive integers. All input integers do not exceed 10^6.

Çıktı

For each test, print the sum of the GCDs of all possible pairs on a separate line.

Örnekler

Örnek 1

Loading
Loading

Not

The answer for the third example is

GCD(125,15) + GCD(125,25) + GCD(15,25) = 5 + 25 + 5 = 35