I am solving HELPVOD but my implementation seems to throw WA on codechef judge. Please help me in finding the error or the test cases it is failing. My implementation:

```
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
int sum,ans;
sum = ans = 0;
for(int i=0;i<n-1;i++)
{
ans = a[i]*a[i+1];
sum += ans;
//<<sum<<" ";
}
cout<<sum<<endl;
return 0;
}
```