


1. Consider the container to be 2-dimensional for simplicity.
2. For any pair of sides ignore all the lines that lie inside that pair of sides.
3. You are not allowed to slant the container.

Consider 'ARR'= {1,8,6,2,5,4,8,3,7} then the vertical lines are represented by the above image. The blue section denotes the maximum water than a container can contain.
The first line contains a single integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer ‘N’ denoting the number of elements in the array/list.
The second line of each test case contains ‘N’ single space-separated integers denoting the elements of the array/list.
For each test case, return a single integer which denotes the maximum area of the container.
You don’t need to print the output, It has already been taken care of. Just implement the given function.
1 <= T <= 100
2 <= N <= 5000
1 <= ARR[i] <= 10^5
Where 'ARR[i]' denotes the elements of the given array/list.
Time limit: 1 sec
The idea is to try all possible pairs as the sides of the container and then calculate the maximum area out of all the pairs.
The steps are as follows:
The idea is to use the two-pointer technique and greedily select the sides of the container. We know that the area of the container is limited by the height of the shorter side and also by the length of the base of the container, so to maximize the area we can remove the side with a shorter length and choose a side that has a bigger length and at the same time keep the length of the base as large as possible.
The steps are as follows: