#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
unordered_map<int,int> freq;
priority_queue<pair<int,int>> maxhp;
for(int i=0;i<n;i++){
cin>>a[i];
freq[a[i]]++;
}
for(auto i=freq.begin();i!=freq.end();i++){
maxhp.push({i->second,i->first});
}
while (maxhp.size()>0){
int j=0;
int s=maxhp.top().first;
for(j=0;j<s;j++){
cout<<maxhp.top().second<<" ";
}
maxhp.pop();
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: