/*第二次来水BC,暑假最后一场了,这次收获不错,水出两题,虽然第二题不知道什么是线段树,但是还是按照自己想法搞出来了,加油*/
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string.h>
#define N 100010
#define M 100000
using namespace std;
long long n, dp[N],pd[N],a[N], tep;
long long Max(long long a,long long b,long long c)
{
long long d=max(a,b);
long long e=max(b,c);
return max(d,e);
}
int main()
{
//freopen("in.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--)
{
memset(dp,0,sizeof(dp));
memset(pd,0,sizeof(pd));
vector <long long > v;
v.clear();
v.push_back(0);
scanf("%lld",&n);
for(int i = 1; i <= n; i++)
{
scanf("%lld",&tep);
v.push_back(tep);
}
v.push_back(0);
dp[1]=0;
for(int i = 2; i <= n;i++)
if(abs(v[i] - v[i - 1])>dp[i-1])
{
dp[i]=abs(v[i] - v[i-1]);
}
else
dp[i] = dp[i - 1];
reverse(v.begin(), v.end());
pd[1]=0;
for(int i = 2; i <= n; i++)
if(abs(v[i] - v[i-1]) > pd[i-1])
pd[i] = abs(v[i] - v[i-1]);
else
pd[i] = pd[i - 1];
reverse(v.begin(), v.end());
long long s = 0;
for(int i=1;i<=n;i++)
{
if(i==1)
s+=pd[n-1];
else if(i==n)
s+=dp[n-1];
else
s+=Max(dp[i-1],abs(v[i+1] - v[i-1]),pd[n-i]);
}
printf("%lld\n",s);
}
return 0;
}