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
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = int(raw_input())

def ap_form(n):
	return n*(n+1)/2;
while(T!=0):
	N = int(raw_input())
	arr = map(int,raw_input().strip().split())
	arr.sort()
	#print arr
	result = 0
	count = 0
	for i in xrange(1,N):
		if arr[i-1] == arr[i]:
			count = count + 1
			if i==N-1:
				result = result + ap_form(count)
		else:
			#print "count",count
			result = result + ap_form(count)
			#print "result",result
			count = 0
		
	print result+len(arr)
	T=T-1