#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'

const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//
//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

const int mx = 2e5+5;
int n;
int a[mx];
ll dp[mx][2];
bool vis[mx][2];

ll recur( int pos, int f )
{
	if( pos >= n-1 ) return 0;
	if( vis[pos][f] ) return dp[pos][f];
	vis[pos][f] = 1;
	ll ret = infLL;
	ret = min( ret, abs( a[pos+1]-a[pos] ) + recur( pos+1, f ) );
	if( !f && pos+2 < n ) ret = min( ret, abs( a[pos+2]-a[pos] ) + recur( pos+2, 1 ) );
	if( !f && pos+2 == n ) ret = min( ret, recur( pos+2, 1 ) );
	dp[pos][f] = ret;
	return ret;
}

int main()
{
	optimize();
	int t;
	cin >> t;
	while(t--) {
		cin >> n;
		for( int i = 0; i <= n+2; ++i ) vis[i][0] = vis[i][1] = 0;
		for( int i = 0; i < n; ++i ) cin >> a[i];
		reverse( a, a+n );
		ll ans = min( recur( 0, 0 ), recur( 1, 1 ) );
		cout << ans << endl;
	}
}





















