Pairwise Sum and Divide
Difficulty: Hard

You are given an array of numbers. Let us denote the array with $A[]$. Your task is very simple. You need to find the value returned by the function $\text{fun}(A)$.

    fun(A)
        sum = 0
        for i = 1 to A.length
            for j = i+1 to A.length
                sum = sum + Floor((A[i]+A[j])/(A[i]*A[j])) 
        return sum
        
In short, this function takes all distinct pairs of indexes from the array and adds the value $ \left \lfloor \frac{A[i]+A[j]}{A[i]\times A[j]}\right \rfloor$ to the sum. Your task is to find the sum.  

**Note:** $\left \lfloor \frac{A}{B} \right\rfloor$ is the integer division function.  

**Input Format**  
The first line contains $T$, the number of test cases to follow.  

Each test case contains two lines: the first line contains $N$, the size of the array, and the second line contains $N$ integers separated by spaces.  

**Output Format**  
The output should contain exactly $T$ lines where the $i^{\text{th}}$ line contains the answer for the $i^{\text{th}}$ test case.  

**Constraints**  
$1 \le T \le 15$  
$1 \le N \le 2 \times 10^5$  
$1 \le \text{Sum of $N$ over all test cases } \le 2 \times 10^5$  
$1 \le A[i] \le 10^9$  

**Sample Input**  

    2
    3
    4 2 3
    3
    1 4 1

**Sample Output**  

    0
    4
    
**Explanation**  
*First Test Case:* $\left \lfloor \frac{6}{8}\right \rfloor + \left \lfloor \frac{7}{12}\right \rfloor + \left \lfloor \frac{5}{6}\right \rfloor = 0$  
*Second Test Case:* $\left \lfloor \frac{5}{4}\right \rfloor + \left \lfloor \frac{2}{1}\right \rfloor + \left \lfloor \frac{5}{4}\right \rfloor = 4$  


Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'solve' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY a as parameter.
#

def solve(a):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
#include<stdio.h>
#include<assert.h>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll A[210004];
void solve()
{
    ll n;
    scanf("%lld",&n);
    assert(n>=1 && n<=200000);
    ll ones=0,twos=0,ans=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&A[i]);
        assert(A[i]>=1 && A[i] <= 1000000000);
        if ( A[i] == 1)    ones++;
        if ( A[i] == 2)    twos++;
    }
    A[n+1] = (1<<30);
    ans = (twos*(twos-1))/2 + (ones*(n-ones)) + (ones*(ones-1));
    printf("%lld\n",ans);
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
        solve();
    }
    return 0;
}
```