Hey i am having this problem with my code. It runs on my test cases and the sample ones but when i submit it, it gives right answer for only a handful.

#include<bits/stdc++.h>

using namespace std;

int main()

{

```
int n;
cin >> n;
int a[n];
for(int i = 0; i< n; i++)
{
cin >> a[i];
}
sort(a, a+n);
long long max = 0;
for(int i = 0; i < n; i++)
{
long long c = a[i]*(n-i);
if(max < c)
{
max = c;
}
}
cout << max;
return 0;
```

}