题目描述
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array of N integers. Find the minimum number of integers you need to delete from the array such that the absolute difference between each pair of integers in the remaining array will become equal.
------ Input Format ------
- The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains an integer N.
- The second line of each test case contains $N space-separated integers A_{1}, A_{2}, \dots, A_{N}$.
------ Output Format ------
For each test case, print a single line containing one integer - the minimum number of integers to be deleted to satisfy the given condition.
------ Constraints ------
$1 ≤ T ≤ 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases does not exceed $5 \cdot 10^{5}$.
----- Sample Input 1 ------
3
2
1 2
5
2 5 1 2 2
4
1 2 1 2
----- Sample Output 1 ------
0
2
2
----- explanation 1 ------
Test case $1$: There is only one pair of integers and the absolute difference between them is $|A_{1} - A_{2}| = |1 - 2| = 1$. So there is no need to delete any integer from the given array.
Test case $2$: If the integers $1$ and $5$ are deleted, the array A becomes $[2, 2, 2]$ and the absolute difference between each pair of integers is $0$. There is no possible way to delete less than two integers to satisfy the given condition.
输入格式
见题面
输出格式
见题面