There are $$$n$$$ trees in a park, numbered from $$$1$$$ to $$$n$$$. The initial height of the $$$i$$$-th tree is $$$h_i$$$.
You want to water these trees, so they all grow to the same height.
The watering process goes as follows. You start watering trees at day $$$1$$$. During the $$$j$$$-th day you can:
Note that you can't water more than one tree in a day.
Your task is to determine the minimum number of days required to water the trees so they grow to the same height.
You have to answer $$$t$$$ independent test cases.
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases.
The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of trees.
The second line of the test case contains $$$n$$$ integers $$$h_1, h_2, \ldots, h_n$$$ ($$$1 \le h_i \le 10^9$$$), where $$$h_i$$$ is the height of the $$$i$$$-th tree.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$ ($$$\sum n \le 3 \cdot 10^5$$$).
For each test case, print one integer — the minimum number of days required to water the trees, so they grow to the same height.
331 2 454 4 3 5 572 5 4 8 3 7 4
4 3 16
Consider the first test case of the example. The initial state of the trees is $$$[1, 2, 4]$$$.
Thus, the answer is $$$4$$$.
Name |
---|