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
def series(x):
	# since for matching 2,2,2,2 count will be 3: and result must be 4C2
	return x*(x+1)/2


for _ in range(int(raw_input())):
	n = int(raw_input())
	data = [int(i) for i in raw_input().split()]
	data.sort()
	total = 0
	count = 0
	for i in range(1,n):
		if data[i-1] == data[i]:
			count += 1
			if i==n-1:
				total += series(count)
		else:
			total += series(count)
			count = 0
	#data length is added for all i=j
	print(total + len(data))