Given an array A[ ] your task is to complete the function max_val which finds the maximum value of abs(i – j) * min(arr[i], arr[j]) where i and j vary from 0 to n-1.
The first line of input contains an integer T denoting the no of test cases then T test cases follow. Each test case contains 2 lines. The First line of each test case contains an integer N denoting the size of the array. In the next line are N space separated values of the array A[ ] .
For each test case in a new line output will be the max values obtained.
Example(To be used only for expected output):
3 2 1 4
8 1 9 4
(i) For the first test case a = 3 and a = 4 and thus result is abs(0-3)*min(3,4) = 9.
(ii) For the second test ase a=8 and a=9 thus result is abs(0-2)*min(8,9) = 16.
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.