#P1598C. Delete Two Elements
Delete Two Elements
No submission language available for this problem.
Description
Monocarp has got an array consisting of integers. Let's denote as the mathematic mean of these elements (note that it's possible that is not an integer).
The mathematic mean of an array of elements is the sum of elements divided by the number of these elements (i. e. sum divided by ).
Monocarp wants to delete exactly two elements from so that the mathematic mean of the remaining elements is still equal to .
Your task is to calculate the number of pairs of positions () such that if the elements on these positions are deleted, the mathematic mean of remaining elements is equal to (that is, it is equal to the mathematic mean of elements of the original array ).
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains one integer () — the number of elements in the array.
The second line contains a sequence of integers (), where is the -th element of the array.
The sum of over all testcases doesn't exceed .
Print one integer — the number of pairs of positions () such that if the elements on these positions are deleted, the mathematic mean of remaining elements is equal to (that is, it is equal to the mathematic mean of elements of the original array ).
Input
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains one integer () — the number of elements in the array.
The second line contains a sequence of integers (), where is the -th element of the array.
The sum of over all testcases doesn't exceed .
Output
Print one integer — the number of pairs of positions () such that if the elements on these positions are deleted, the mathematic mean of remaining elements is equal to (that is, it is equal to the mathematic mean of elements of the original array ).
Samples
Note
In the first example, any pair of elements can be removed since all of them are equal.
In the second example, there is no way to delete two elements so the mathematic mean doesn't change.
In the third example, it is possible to delete the elements on positions and , or the elements on positions and .