Given an array A of N numbers, find the number of distinct pairs (i, j) such that j ≥i and A[i] = A[j].

First line of the input contains number of test cases T. Each test case has two lines, first line is the number N, followed by a line consisting of N integers which are the elements of array A.

For each test case print the number of distinct pairs.  

Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 10^6 
-10^6 ≤ A[i] ≤ 10^6 for 0 ≤ i < N

SAMPLE INPUT
3
4
1 2 3 4
3
1 2 1
5
1 1 1 1 1

SAMPLE OUTPUT
4
4
15
for _ in range(input()):
    n=input()
    arr=map(int,raw_input().split())
    arr=sorted(arr)
    i=0
    c=0
    temp=arr[i]
    count=0
    j=0
    #print arr
    #print n
    while i<n:
        j=i
        #print "j outside loop",j
        while (j<=n-1 and arr[i]==arr[j]):
            #print "j",j
            j=j+1
            c=c+1
            
        count=count+c
        c=0
        i=i+1
        
    print count
    
    
#In inner while loop, writing arr[i]==arr[j] is necessary bcoz otherwise compiler will give error that list index is out range.First we will check that index is in range only then we have to check for condition.Great question for debugging competition.