ans1=0;//waste var in this approach- was used in other approach.
sum[0]=0;
arr[0]=abs(op[0]-op[1])>op[1]-1?op[0]:1;/*Initialising arr[0] as op[0] if it maximises the difference b/w op[1] & op[0]. Else its given 1 by default. */
//cout<<arr[0]<<" "; - Used while debugging. Ignore.
for(i=1;i<n;i++)
{
arr[i]=abs(op[i]-arr[i-1])>abs(arr[i-1]-1)?op[i]:1;/*An attempt to construct ideal array by giving arr[i] the value of op[i] if the diff b/w previous element and op[i] is more than what it would be if arr[i] was assigned 1. */
sum[i]= sum[i-1]+abs(arr[i]-arr[i-1]);/*Sum array WAS used to directly find max sum in previos approach (which miserably failed). Lol. Retained array in case an idea strikes me in future.*/
//cout<<arr[i]<<" ";-used for debugging
}
//cout<<endl;-used for debugging.
return sum[n-1];
}
int main(){
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
cin>>t;//test cases
while(t--)
{
int n;//size of array
cin>>n;
int arr[n];//Baow-Chiki-Baow-Baow.
int i,j,k;
longlongint sum=0;//I think i used it to store final ans of sum. I guess so... :p
for(i=0;i<n;i++)
cin>>arr[i];
sum = solve(arr,n);//Function call if i am not wrong
cout<<sum<<endl;//I am definetely sure i used it to print output. :p XD