#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(pair<int, double> a, pair<int, double> b)
{
if(a.second == b.second) return a.first < b.first;
return a.second > b.second;
}
vector<int> solution(int N, vector<int> stages) {
vector<int> answer;
vector<int> count(N+1,0);
for(int i=0; i < stages.size(); i++)
{
count[stages[i]-1]++;
}
int sum = count[N];
vector<pair<int,double>> rate(N);
for(int i=N-1;i>=0;i--)
{
sum += count[i];
rate[i] = { i+1, sum != 0 ? count[i] / (double)sum : 0.0 };
}
sort(rate.begin(), rate.end(), compare);
for(auto a : rate) answer.push_back(a.first);
return answer;
}