Free Drives

3.2

19 votes
Problem

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

Time Limit: 2
Memory Limit: 256
Source Limit:
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.

Editor Image

?