


Given N = 5,
and ARR[] = {1, 3, 5, 4, 2}
Therefore, we can see that three ninjas with ability 3,4 and 5 will give us the maximum ability and will be called great therefore the output will be 60.
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case contains a single integer N, where ‘N’ is the array’s size.
The second line of each test case contains ‘N’ space-separated integers, denoting the elements of the array.
For each test case, print the maximum product of abilities that can be had with given candidates.
The output of each test case will be printed in a separate line.
1 <= T <= 5
3 <= N <= 3000
-500 <= ARR[i] <= 500
Where ARR[i] is the array element at index I.
Time Limit: 1 sec
You do not need to print anything, it has already been taken care of. Just implement the given function.
The main idea is to sort the array in increasing order. The answer would be the maximum product of the three greatest numbers or product of the 2 smallest numbers and the greatest number.
The idea is to find the three greatest and 2 smallest numbers by traversing the array. Therefore, our approach goes like this :