Rayan has n artifacts with power levels a1,a2,…,an.
The resonance of an arrangement is the sum of absolute differences between adjacent elements:
∑i=1n−1∣ai−ai+1∣
Rayan can reverse exactly one contiguous segment, or leave the arrangement unchanged. Find the maximum possible resonance.
Input
The first line contains the number of test cases t (1≤t≤100).
Each test case consists of:
- The first line contains n (1≤n≤1000), the number of artifacts.
- The second line contains n integers a1,a2,…,an (∣ai∣≤109).
The sum of n over all test cases does not exceed 5000.
Output
For each test case, print the maximum possible resonance.