#K42512. Unique Absolute Differences

    ID: 27104 Type: Default 1000ms 256MiB

Unique Absolute Differences

Unique Absolute Differences

You are given an array of N integers. Your task is to compute the number of unique absolute differences that can be formed between any two distinct elements in the array. The absolute difference between two integers \(a\) and \(b\) is defined as \(\lvert a - b \rvert\).

For example, if the array is [10, 20, 30], the unique absolute differences are computed as follows:

  • \(\lvert 10-20 \rvert = 10\)
  • \(\lvert 10-30 \rvert = 20\)
  • \(\lvert 20-30 \rvert = 10\) (which is a repeat)

Thus, there are 2 unique differences: 10 and 20.

Read the input and output for each test case as described below.

inputFormat

The first line of input contains an integer T, which is the number of test cases. Each test case consists of two lines:

  1. The first line contains an integer N, the number of elements in the array.
  2. The second line contains N space-separated integers representing the array elements.

outputFormat

For each test case, output a single integer on a new line representing the number of unique absolute differences among all pairs of numbers in the array.

## sample
2
3
10 20 30
4
-5 0 5 10
2

3

</p>