free-drives-2
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

Amer cabs has released a scheme through which a user gets a free drive when he shares a reference code with another Amer app user. Given N number of app users, output total number of free drives gained by all of them. Two same users cannot share reference code more than once.  

Input Format 
The first line contains the number of test cases T, T lines follow. 
Each line then contains an integer N, the total number of Amer App Users.

Output Format

Print the number of Free Drives for each test-case in a new line.

Constraints

1 ≤ T ≤ 1000
0 < N < 10^6

SAMPLE INPUT
2
1
2

SAMPLE OUTPUT
0
1

Explanation

Case 1 : Single user shares no reference code, hence 0 free drives. 

Case 2 : There are 2 app users, so reference code is shared once, hence 1 free drive.


t=eval(input())
while t :
	t-=1
	n=eval(input())
	if n==1 :
		print("0")
	else :
		print(n*(n-1)/2)


t = int(eval(input()))
while t > 0:
	n = int(eval(input()))
	print(n*(n-1)//2)
	t -= 1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = int(eval(input()))
for i in range(t):
	n = int(eval(input()))
	k = n*(n-1)
	k = k/2
	print(k)


t = int(eval(input()))
while t > 0:
	n = int(eval(input()))
	print(n*(n-1)//2)
	t -= 1


kases = int(eval(input()))
for kase in range(kases):
	free = 0
	N = int(eval(input()))
	for i in range(1,N+1):
	    free = free + (N-i)
	print(free)
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import sys
data=sys.stdin.readlines()
for i in range(len(data)-1):
	a=int(data[i+1])
	if a==1:
		print(0)
	else:
		e=a*(a-1)/2
		print(e)


if __name__=='__main__':
	for i in range(0,int(eval(input()))):
		n = int(eval(input()))
		print(((n*(n-1))//2))
		


test=int(eval(input()))
while(test>0):
	N=int(eval(input()))
	sum=0
	for i in range(1,N):
		sum+=i
	print(sum)
	test-=1


noc = eval(input())
while noc:
	noc-=1
	cur = eval(input())
	print(cur * (cur - 1) /2)


for tc in range(eval(input())):
	n=int(eval(input()))
	print((n*(n-1)//2))