#include #include #include #include #include #include #include #include #define logk(x) (int)(log(double(x))/log(2.0)) using namespace std; const int MAXN = 100000+100; int a[MAXN],max1[MAXN]; bool cmp(int a,int b){ return a>b; } void solve(){ int n; long long sum=0; scanf("%d",&n); for(int i=0;i3)current_max=max(abs(a[i+1]-a[i-1]),max1[3]); else current_max=abs(a[i+1]-a[i-1]); sum+=1LL*current_max; } else if(abs(a[i]-a[i-1])==max1[1]||abs(a[i+1]-a[i])==max1[1]){ if(n>3)current_max=max(abs(a[i+1]-a[i-1]),max1[2]); else current_max=abs(a[i+1]-a[i-1]); sum+=1LL*current_max; } else{ if(n>3)current_max=max(abs(a[i+1]-a[i-1]),max1[1]); else current_max=abs(a[i+1]-a[i-1]); sum+=1LL*current_max; } } } cout<