MKEQUAL - Make them equal !


You have an array containing N elements. At any move, you choose two indices i and j (0 ≤ i, j < N and ij) and increment value at one index and decrement value at other index. You can make this move any number of times. What is the maximum number of elements which can have the same value (after any number of moves) ?

Input

First line consists of T, the number of test cases. (1 ≤ T ≤ 100)

T sets follow. Each set contains N, the number of elements in the array, in the first line. (1 ≤ N ≤ 100000)

Next line of each set consists of N space separated integers (0 ≤ value ≤ 100000)

Output

Output T lines each containing the required answer.

Example

Input:
1
4
1 2 3 4

Output: 
3

hide comments
surajgupta375: 2022-03-26 10:13:43

a bit tricky but once get the logic becomes simple

kprock41951: 2020-07-15 11:08:20

HINT:

[NG]: Nobody asked you for one. Also read the footer.

Last edit: 2020-07-15 19:58:01
kumar_anubhav: 2020-06-02 14:17:55

please make it clear that, can we choose same index more than one time and what if array size is equal to 1??

sayan_244: 2019-12-13 09:55:31

Took me a while to figure out lol..
2 cases are there only!
Nice question!

vaibhav18_: 2019-06-21 11:10:20

just open the spoj toolkit try different cases even if u dont see the question u can do the answer

ankkt16: 2019-01-29 05:39:31

what to print in the case when none of the elements could be made to same no

malcolm123_ssj: 2019-01-25 07:48:13

consider only 2 cases: when sum is divisible by n and when not divisible by n

wrzoboo: 2018-06-05 18:10:57

Really easy one, there are only two options to consider. (Hint: think with zeroes ;) )

sinersnvrsleep: 2018-04-05 15:35:05

no need of binary search just simple adhoc

ameyanator: 2018-03-27 15:37:06

At first I thought we'd have to use some pre defined property but then nah just read the question carefully


Added by:Pandian
Date:2013-10-15
Time limit:0.5s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own