 A difference of values and indexes
##### Submissions: 529   Accuracy: 15.56%   Difficulty: Medium   Marks: 4

Given a unsorted array, you need to find the maximum difference of absolute values of elements and indexes, i.e., for i < j, calculate maximum of | A[i] - A[j] | + | i - j |.

Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. The first line of each test case contains N where N is the size of array. The second line of each test case contains N space separated integers denoting the array elements.

Output: For each testcase in the new line, print the maximum diiference as given in question.

Constraints:
1 <= T <= 100
1 <= N <= 106
0 <= |A[i]| <= 106

Example:
Input:

1
3
1 3 -1
Output:
5

Explanation:
Testcase 1:
Maximum difference comes from indexes 1, 2 i.e | 3 - (-1) | + | 1 - 2 | = 5

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: SIDG

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.