This is a relatively easy math problem, made much easier if you know a touch of combinatorics. We get $n$ numbers, $1 \leq n \leq 2*10^5$, then we find the minimum element and maximum element. Then get corresponding counts for the minimum and maximum. Now, the only check left is whether the minimum and maximum are the same value. If they are not the same value, then I just need the product of the counts. Otherwise, we want the number of ways I can choose any $2$ elements from $m$, where $m$ is the count of elements equal to minimum and maximum. This is a combination.