The problem statement is: http://www.iarcs.org.in/inoi/2014/zco2014/zco2014-2a.php

Here is my code:

My logic is that if we sort the budgets and find the maximum value of i-th budget times (n-i). (0-based index). n-i means the number of people having budget greater than or equal to ith-budget.

```
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<stack>
#include<cmath>
#include<utility>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for(int i = 0;i < n;i++) cin >> a*;
sort(a,a+n);
long long int ans = 0;
for(int i = 0;i < n;i++) {
ans = (ans> ((n-i)*a*) )?ans:(n-i)*a*;
}
cout << ans;
return 0;
}
```