Trong trường hợp đề bài hiển thị không chính xác, bạn có thể tải đề bài tại đây: Đề bài
Luna is analyzing a set of numbers, consisting of ~n~ integer values. Let ~k~ be the mathematic mean of all the numbers in this set (note that ~k~ may not be an integer).
Luna defines a pair of exception numbers as two values that, when removed from the set, keep the mathematic mean of the remaining ~n - 2~ numbers unchanged at ~k~.
Your task is to determine the number of pairs of indices ~(i, j) (i < j)~ such that removing the numbers at these indices keeps the mathematic mean of the remaining ~n - 2~ numbers equal to ~k~.
The mathematic mean of a set is calculated by dividing the sum of all the numbers by the number of elements.
Input
The first line contains one integer ~n~ ~(3 ≤ n ≤ 2 · 10^5)~ - the number of elements in the array.
The second line contains a sequence of integer ~a_1, a_2,..., a_n~ ~(0 ≤ a_i ≤ 10^9)~, where ~a_i~ is the ~i^{th}~ element of the array.
Output
Print one integer - the number of pairs of positions ~(i, j) i < j~ such that if the elements on these positions are deleted, the mathematic mean of ~n - 2~ remaining elements is equal to ~k~ (that is, it is equal to the mathematic mean of ~n~ elements of the original array ~a~).
Sample Input 1
5
1 4 7 3 5
Sample Ouput 1
2
Note
It is possible to delete the elements on positions 1 and 3, or the elements on positions 4 and 5. ~k = 4~.
Bình luận