Gellyfish hates math problems, but she has to finish her math homework:
Gellyfish is given an array of $$$n$$$ positive integers $$$a_1, a_2, \ldots, a_n$$$.
She needs to do the following two-step operation until all elements of $$$a$$$ are equal:
Now, Gellyfish asks you for the minimum number of operations to achieve her goal.
It can be proven that Gellyfish can always achieve her goal.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 5000$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 5000$$$) — the length of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \leq a_i \leq 5000$$$) — the elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$.
For each test case, output a single integer — the minimum number of operations to achieve her goal.
3312 20 3061 9 1 9 8 136 14 15
4 3 3
In the first test case, the following is a way that minimizes the number of operations: