You are given an array of integers ‘NUMS’. The beauty of this array can be defined as:
The sum of absolute difference of each two consecutive elements.
In one operation you can reverse one subarray of ‘NUMS’. Your task is to find maximum beauty by performing the operation exactly once.
Input Format:
The first line contains an integer ‘T’, which denotes the number of test cases to be run. Then, the ‘T’ test cases follow.
The first line of each test case contains a single positive integer ‘N’ denoting the size of the ‘NUMS’ array.
The second line of each test case contains ‘N’ space-separated positive integers denoting the array elements.
Output Format:
For each test case, print a single line containing a single integer denoting the maximum beauty of the array ‘NUMS’ by doing the operation described above exactly once.
The output of each test case will be printed in a separate line.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.
Constraints:
1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^5
1 <= NUMS[i] <= 10^8
Where ‘N’ is the size of the array ‘NUMS’ and ‘NUMS[i]’ is the ith element of the array.
Time Limit: 1 sec