This paased sample test case but not accepted by online judge . plz tell me what is wrong with this code

using namespace std;

int main()

{

```
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin>>t;
while(t--)
{
long long n;
cin>>n;
long long arr[n];
for(long long i=0;i<n;i++)
{
cin>>arr[i];
}
long long ans=0,maxi=0,max1=0,res;
for(long long i=0;i<n-1;i++)
{
long long ans = arr[i]*arr[i+1]+max((arr[i]-arr[i+1]),(arr[i+1]-arr[i]));
maxi = max(maxi,ans);
}
res = (arr[0]*arr[n-1])+max((arr[0]-arr[n-1]),(arr[n-1]-arr[0]));
max1 = max(maxi,res);
cout<<max1<<"\n";
}
```

}