2017icpc沈阳
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int a[maxn];
int main(){
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
for( int i = 1;i <= n;i++ ){
scanf("%d",&a[i]);
}
int cnt1 = 0;
for( int i = 2;i <= n;i++ ){
cnt1 += a[i]-a[i-1]-1;
}
int dt = min( a[n]-a[n-1]-1,a[2]-a[1]-1);
printf("%d\n",cnt1-dt);
}
return 0;
}