CF2014C.Robin Hood in Town

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Robin Hood in Town

In Sherwood, we judge a man not by his wealth, but by his merit.

Look around, the rich are getting richer, and the poor are getting poorer. We need to take from the rich and give to the poor. We need Robin Hood!

There are nn people living in the town. Just now, the wealth of the ii-th person was aia_i gold. But guess what? The richest person has found an extra pot of gold!

More formally, find an aj=max(a1,a2,,an)a_j=max(a_1, a_2, \dots, a_n), change aja_j to aj+xa_j+x, where xx is a non-negative integer number of gold found in the pot. If there are multiple maxima, it can be any one of them.

A person is unhappy if their wealth is strictly less than half of the average wealth^{\text{∗}}.

If strictly more than half of the total population nn are unhappy, Robin Hood will appear by popular demand.

Determine the minimum value of xx for Robin Hood to appear, or output 1-1 if it is impossible.

^{\text{∗}}The average wealth is defined as the total wealth divided by the total population nn, that is, umain\frac{ um a_i}{n}, the result is a real number.

Input

The first line of input contains one integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains an integer nn (1n21051 \le n \le 2\cdot10^5) — the total population.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1061 \le a_i \le 10^6) — the wealth of each person.

It is guaranteed that the sum of nn across all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output one integer — the minimum number of gold that the richest person must find for Robin Hood to appear. If it is impossible, output 1-1 instead.

Note

In the first test case, it is impossible for a single person to be unhappy.

In the second test case, there is always 11 happy person (the richest).

In the third test case, no additional gold are required, so the answer is 00.

In the fourth test case, after adding 1515 gold, the average wealth becomes 254\frac{25}{4}, and half of this average is 258\frac{25}{8}, resulting in 33 people being unhappy.

In the fifth test case, after adding 1616 gold, the average wealth becomes 315\frac{31}{5}, resulting in 33 people being unhappy.

Samples

6
1
2
2
2 19
3
1 3 20
4
1 2 3 4
5
1 2 3 4 5
6
1 2 1 1 1 25
-1
-1
0
15
16
0

在线编程 IDE

建议全屏模式获得最佳体验