Cant find the error in this code, getting WA

Hello, could you please check why my code is not working for this problem: CodeChef: Practical coding for everyone
This is my code:
#include
#include
#include
#include
#include
using namespace std;
int main() {
long long int n;
cin>>n;
vector list;
for(long long int i=0;i<n;i++)
{ long long int f;
cin>>f;
list.push_back(f);
}
sort(list.begin(),list.end());
long long int values[n];
for(long long int i=0;i<n;i++){
values[i]=list[i]*(n-i);
}
long long int max =values;
for(long long int i=0;i<n-1;i++){
if(values[i]<values[i+1]){
max = values[i+1];
}
}
cout<<max<<endl;
return 0;}
The logic is very similiar to this correct code: Solution: 38027149 | CodeChef
Could someone pls tell the edge case for which it isnt working