#include #include #include using namespace std; #define ll __int64 ll dis[100050]; ll a[100050]; ll max(ll a,ll b) { return a>b?a:b; } /* ll abs(ll aa) { if(aa<0)return -aa; else return aa; }*/ int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); memset(dis,0,sizeof(dis)); memset(a,0,sizeof(a)); for(int i=0;i=maxn) { output+=abs(a[i]-a[i+2]); } else { ll tmpma=max(abs(a[i+1]-a[i+2]),abs(a[i]-a[i+1])); if(tmpma==maxn) { ll tmpmi=min(abs(a[i+1]-a[i+2]),abs(a[i]-a[i+1])); if(tmpmi==ci) { output+=zaici; } else output+=ci; } else output+=maxn; } } printf("%I64d\n",output); } }