#include <iostream>
#include <vector>
using namespace std;
bool comp(string s1, string s2){
return s1.length() > s2.length();
}
signed main() {
int n;
cin >> n;
vector<string> a(n);
for(auto &i: a)
cin >> i;
sort(a.begin(),a.end(),comp);
for(auto &i:a)
cout << i << ' ';
#include <iostream>
#include <vector>
using namespace std;
bool comp(string s1, string s2){
return s1.length() > s2.length();
}
signed main() {
int n;
cin >> n;
vector<string> a(n);
for(auto &i: a)
cin >> i;
sort(a.begin(),a.end(),comp);
for(auto &i:a)
cout << i << ' ';
}