#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
vector <int> tong[12];
int num[10];
int a[100010];
int bit (int x)
{
if (x == 0) return 0;
return bit (x / 10) + 1;
}
int main()
{
int n;
scanf ("%d", &n);
int mx = 0;
for (int i = 1; i <= n; i ++) scanf ("%d", &a[i]), mx = max(mx, bit(a[i]));
for (int i = 1; i <= mx; i ++)
{
for (int j = 0; j <= 9; j ++)
{
tong[j].clear();
}
for (int j = 1; j <= n; j ++)
{
int pos = (a[j] % ((int) pow(10, i))) / ((int) pow(10, i - 1));
tong[pos].push_back(a[j]);
num[pos] ++;
}
int tot = 0;
int id = 0;
for (int j = 1; j <= n; j ++)
{
while (num[id] == 0) id ++;
a[++ tot] = tong[id].front();
tong[id].erase(tong[id].begin());
num[id] --;
}
}
for (int i = 1; i <= n; i ++) printf("%d ", a[i]);
puts("");
return 0;
}