#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int last,curr,tmp;
long long sum=0;
cin>>last;
while(--n){
cin>>tmp;
curr=tmp;
curr-=last;
if(curr<0)curr=-curr;
sum+=curr-1?curr-1:0;
last=tmp;
}
cout<<sum<<endl;
}
}
Comments
Post a Comment