#K4996. Unique Gift Bags

    ID: 28758 Type: Default 1000ms 256MiB

Unique Gift Bags

Unique Gift Bags

In this problem, you are given T test cases. For each test case, you receive a list of treat types. A gift bag is defined as a combination of two distinct treat types, and its total number is calculated by the formula:

$$\frac{k \times (k-1)}{2}$$

where k is the number of unique treat types in that test case. If a test case contains fewer than two unique treat types, then no gift bag can be made (the answer is 0).

Your task is to compute and output the number of unique gift bag combinations for each test case.

inputFormat

The input is read from standard input and is formatted as follows:

  • The first line contains a single integer T, the number of test cases.
  • For each test case, the first line contains an integer N, which is the number of treats.
  • The next line contains N space-separated integers representing the treat types.

outputFormat

For each test case, print a single line containing the number of unique gift bag combinations possible.

## sample
2
4
1 2 3 4
3
1 2 2
6

1

</p>