/*Copyright saksham441*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define take long long int num[n];for (int i=0;i<n;i++){cin>>num[i];}
#define chaap for (int i=0;i<n;i++){cout<<num[i]<<" ";}cout<<endl
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vchaap for (int i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl
#define endl "\n"
#define printdp for (int i=0;i<=wt;i++){for(int il=0;il<=n;il++){cout<<dp[i][il]<<" ";}cout<<endl;}
#define f for (j=0;j<n;j++)
void solve(){
	ll j;
	ll n;
	cin>>n;
	//cout<<n<<endl;
	ll num[n];
	 for (j=0;j<n;j++){
		cin>>num[j];
	 }
	 if (n==2){
	 	cout<<0<<endl;
	 	return;
	 }
	ll sum[n];
	ll s=0;
	sum[0]=0;
	s=num[0];
	for (j=1;j<n;j++){
	//	cout<<"Hd"<<endl;
		ll dif;
		dif=num[j-1]-num[j];
		if (dif<0){
			dif=-dif;
		}
		sum[j]=sum[j-1]+dif;
		s+=num[j];
	}

	ll sum_prev[n];
	ll sum_next[n];
	ll temp;
	sum_prev[0]=0;
	sum_next[0]=s;
	for (j=1;j<n;j++){
		ll dif;
		dif=num[j-1]-num[j];
		if (dif<0){
			dif=-dif;
		}
		sum_next[j]=s-dif;
	}
	s=sum[n-1];
	//cout<<s<<endl;
	vector<ll>v;
	for (j=2;j<n;j++){
		ll dif;
		dif=num[j-2]-num[j];
		if (dif<0){
			dif=-dif;
		}
		v.pb(s-sum[j]+sum[j-2]+dif);
	}
	v.pb(s-sum[1]);
	v.pb(sum[n-2]);
	ll min=v[0];
	for (j=0;j<v.size();j++){
		if (min>v[j]){
			min=v[j];
		}
	}
	cout<<min<<endl;

}
int main(){
	fast;
	ll t;
	cin>>t;
	while (t--){
		solve();
	}
}