find-pairs-3
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

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
2
4
1 2 3 4
3
1 2 1

SAMPLE OUTPUT
4
4


for i in range(eval(input())):
	su=0
	n=eval(input())
	a=list(map(int,input().split()))
	for k in range(n):
		for l in range(n):
			if l>=k and a[k]==a[l]:
				su+=1
	print(su)


t=eval(input())
for k in range(0,t):
	n=eval(input())
	a=input()
	a=list(map(int,a.split()))
	c=0
	for i in range(0,n):
		for j in range(i,n):
			if a[i]==a[j]:
				c=c+1
	print(c)
	



n=int(input())
for j in range(n):
	n=int(input())
	s=list(map(int,input().split()))
	i=0
	count=0
	for k in range(n):
		i=k
		while i<n:
			if s[k]==s[i]:
				count+=1
			i+=1
	print(count)


from itertools import combinations
a=int(input())
for i in range(0,a):
	b=int(input())
	l=list(map(int,input().split()))
	l1=list()
	for i in range(0,b):
		for j in range(0,b):
			if(j<=i and l[i]==l[j]):
				
				l1.append((i,j))
				
	print(len(l1))	
	



x = int(eval(input()))
for i in range(x):
	a=[];
	n = int(eval(input()));
	a = list(map(int,input().split()))
	tot = len(a);
	for i in range(n-1):
		for j in range(i+1,n):
			if a[i]==a[j]:
				tot+=1
	print(tot)