#include #include #include #include #include #include #include #include #include #define F first #define S second #define mp make_pair using namespace std; typedef __int64 LL; const int maxn = 1e5 + 10; LL h[maxn]; LL maxsum[maxn][25]; void RMQ(int n) { for(int j=1; j<=20; j++) for(int i=1; i<=n; i++) { if(i+(1<<(j-1))<=n) { maxsum[i][j]=max(maxsum[i][j-1],maxsum[i+(1<<(j-1))][j-1]); //minsum[i][j]=min(minsum[i][j-1],minsum[i+(1<<(j-1))][j-1]); } } } int main() { int T,n,k,q; scanf("%d",&T); while(T--) { scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%I64d",&h[i]); for(int i=1;i<=n-1;i++) { maxsum[i][0]=abs(h[i+1]-h[i]); } RMQ(n-1); LL ans=0; k=log10(n-1-2+1.0)/log10(2.0); ans+=max(maxsum[2][k],maxsum[n-1-(1<=1) { k=log10(i-2-1+1.0)/log10(2.0); sum1=max(maxsum[1][k],maxsum[i-2-(1<