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 factorial(n):
	fact = 1
	while n:
		fact = fact * n
		n -= 1
	return fact

testcases = input()
output = []
index = 0
while index < testcases:
	length = input()
	array = raw_input().split(" ")
	array = [int(i) for i in array]
	arrayDict = {}

	for i in array:
		if arrayDict.has_key(i):
			c = arrayDict.get(i) + 1
			arrayDict.update({i: c})
		else:
			arrayDict.update({i: 1})
		
	count = 0

	for value in arrayDict.values():
		if value > 2:
			value += (factorial(value) / (2 * factorial(value-2)))
		if value == 2:
			value += 1
		count += value
	index += 1
	output.append(count)

for i in output:
	print i