We call an ordered pair of positive integers $$$(x,z)$$$ beautiful if there exists an integer $$$y$$$ such that [ x < y < z, ] $$$x$$$ divides $$$y$$$, and $$$y$$$ divides $$$z$$$.
The integer $$$y$$$ may be any integer; it does not have to occur in the array.
You are given several arrays. For each array, count the number of ordered pairs of indices $$$(i,j)$$$ such that $$$i \ne j$$$ and $$$(a_i,a_j)$$$ is beautiful.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — the length of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5\cdot 10^6$$$.
For each test case, print one integer — the number of ordered pairs of indices $$$(i,j)$$$ such that $$$i \ne j$$$ and $$$(a_i,a_j)$$$ is beautiful.
3 8 1 2 3 4 6 8 4 8 2 2 2 5 1 4 1 4 4
7 0 6
In the first test case, the beautiful ordered pairs of values, with repetitions listed only once, are [ (1,4), (1,6), (1,8), (2,8). ] The values $$$4$$$ and $$$8$$$ each occur twice. Consequently, these value pairs correspond to $$$2+1+2+2=7$$$ ordered pairs of indices.
For example, $$$(2,8)$$$ is beautiful: we may choose $$$y=4$$$, because $$$2 \lt 4 \lt 8$$$, $$$2$$$ divides $$$4$$$, and $$$4$$$ divides $$$8$$$.
In the second test case, all values are equal, so the strict inequality in the definition can never hold.
In the third test case, every occurrence of $$$1$$$ can be paired with every occurrence of $$$4$$$. This gives $$$2\cdot3=6$$$ beautiful ordered pairs of indices.