#P1900D. Small GCD

Small GCD

Description

Let aa, bb, and cc be integers. We define function f(a,b,c)f(a, b, c) as follows:

Order the numbers aa, bb, cc in such a way that abca \le b \le c. Then return gcd(a,b)\gcd(a, b), where gcd(a,b)\gcd(a, b) denotes the greatest common divisor (GCD) of integers aa and bb.

So basically, we take the gcd\gcd of the 22 smaller values and ignore the biggest one.

You are given an array aa of nn elements. Compute the sum of f(ai,aj,ak)f(a_i, a_j, a_k) for each ii, jj, kk, such that 1i<j<kn1 \le i < j < k \le n.

More formally, compute i=1nj=i+1nk=j+1nf(ai,aj,ak).\sum_{i = 1}^n \sum_{j = i+1}^n \sum_{k =j +1}^n f(a_i, a_j, a_k).

题面翻译

a,b,c a, b, c 为整数,定义 f(a,b,c) f(a, b, c) 如下:

将三个数排序,使得 abc a \le b \le c 。则函数返回 gcd(a,b) \gcd(a, b) , 这里 gcd(a,b) \gcd(a, b) 表示 最大公约数 (GCD) 。简而言之,函数返回较小的两个数的最大公约数。

你会得到数组 a a ,包含 n n 个元素。求 f(ai,aj,ak) f(a_i, a_j, a_k) 之和,其中 1i<j<kn 1 \le i< j < k \le n

形式化的讲,求 i=1nj=i+1nk=j+1nf(ai,aj,ak) \sum_{i = 1}^n \sum_{j = i+1}^n \sum_{k =j +1}^n f(a_i, a_j, a_k)

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t101 \le t \le 10). The description of the test cases follows.

The first line of each test case contains a single integer nn (3n81043 \le n \le 8 \cdot 10^4) — length of the array aa.

The second line of each test case contains nn integers, a1,a2,,ana_1, a_2, \ldots, a_n (1ai1051 \le a_i \le 10^5) — elements of the array aa.

It is guaranteed that the sum of nn over all test cases does not exceed 81048 \cdot 10^4.

Output

For each test case, output a single number — the sum from the problem statement.

输入数据 1

2
5
2 3 6 12 17
8
6 12 8 10 15 12 18 16

输出数据 1

24
203

Note

In the first test case, the values of ff are as follows:

  • i=1i=1, j=2j=2, k=3k=3, f(ai,aj,ak)=f(2,3,6)=gcd(2,3)=1f(a_i,a_j,a_k)=f(2,3,6)=\gcd(2,3)=1;
  • i=1i=1, j=2j=2, k=4k=4, f(ai,aj,ak)=f(2,3,12)=gcd(2,3)=1f(a_i,a_j,a_k)=f(2,3,12)=\gcd(2,3)=1;
  • i=1i=1, j=2j=2, k=5k=5, f(ai,aj,ak)=f(2,3,17)=gcd(2,3)=1f(a_i,a_j,a_k)=f(2,3,17)=\gcd(2,3)=1;
  • i=1i=1, j=3j=3, k=4k=4, f(ai,aj,ak)=f(2,6,12)=gcd(2,6)=2f(a_i,a_j,a_k)=f(2,6,12)=\gcd(2,6)=2;
  • i=1i=1, j=3j=3, k=5k=5, f(ai,aj,ak)=f(2,6,17)=gcd(2,6)=2f(a_i,a_j,a_k)=f(2,6,17)=\gcd(2,6)=2;
  • i=1i=1, j=4j=4, k=5k=5, f(ai,aj,ak)=f(2,12,17)=gcd(2,12)=2f(a_i,a_j,a_k)=f(2,12,17)=\gcd(2,12)=2;
  • i=2i=2, j=3j=3, k=4k=4, f(ai,aj,ak)=f(3,6,12)=gcd(3,6)=3f(a_i,a_j,a_k)=f(3,6,12)=\gcd(3,6)=3;
  • i=2i=2, j=3j=3, k=5k=5, f(ai,aj,ak)=f(3,6,17)=gcd(3,6)=3f(a_i,a_j,a_k)=f(3,6,17)=\gcd(3,6)=3;
  • i=2i=2, j=4j=4, k=5k=5, f(ai,aj,ak)=f(3,12,17)=gcd(3,12)=3f(a_i,a_j,a_k)=f(3,12,17)=\gcd(3,12)=3;
  • i=3i=3, j=4j=4, k=5k=5, f(ai,aj,ak)=f(6,12,17)=gcd(6,12)=6f(a_i,a_j,a_k)=f(6,12,17)=\gcd(6,12)=6.
The sum over all triples is 1+1+1+2+2+2+3+3+3+6=241+1+1+2+2+2+3+3+3+6=24.

In the second test case, there are 5656 ways to choose values of ii, jj, kk. The sum over all f(ai,aj,ak)f(a_i,a_j,a_k) is 203203.