it seems that my program is correct and it successfully runs all test cases but still i get wrong answer can anyone help me
Que link :- CodeChef: Practical coding for everyone
here is the code
#include<bits/stdc++.h>
using namespace std;
//@Himanshu_nobee
#define f(i,s,e) for(long long i=s;i<e;i++)
#define endl "\n"
#define ll long long
int t;
int main()
{
//@Himanshu_nobee
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin>>t;
while(t--)
{
//@Himanshu_nobee
ll n,q,x=0,y,sum=0;
cin>>n;
ll a[n],b[n-1];
f(i,0,n)cin>>a[i];
// f(i,0,n-1) b[i]+=a[i+1]-a[i];
for(int i=0;i<n-2;i++)
{
int k=i+1;
for(int j=i+2;j<n;j++)
{
ll ans=(a[k]-a[i])*(a[j]-a[k]);
while((k<j-1)&&(ans<(a[k+1]-a[i])*(a[j]-a[k+1])))
{
ans=(a[k+1]-a[i])*(a[j]-a[k+1]);
k++;
}
sum+=ans;
}
}
cout<<sum<<endl;
}
}