Number of pairs with maximum sum
Easy Accuracy: 41.79% Submissions: 3464 Points: 2

Given an array arr[], count number of pairs arr[i], arr[j] such that arr[i] + arr[j] is maximum and i < j.

Example:
Input  : arr[] = {1, 1, 1, 2, 2, 2}
Output : 3
Explanation: The maximum possible pair
sum where i is less than j is  4, which is given
by 3 pairs, so the answer is 3
the pairs are (2, 2), (2, 2) and (2, 2).

CONSTRAINTS:
1<=T<=100
1<=a[i],n<=105

INPUT:
2
6
1 1 1 2 2 2
6
1 4 3 3 5 1
OUTPUT:
3
1