//普通版的桶排序
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#define N 100000
using namespace std;
int a[N];
int c[10];
int bucket[10][N];
int Max,len;
void init(int n)
{
len=0;
Max=0;
for(int i=1; i<=n; i++)
{
scanf("%d",&a[i]);
Max=max(a[i],Max);
}
while(Max)
{
Max/=10;
len++;
}
}
void print(int n)
{
for(int i=1; i<=n; i++)
printf("%d ",a[i]);
printf("\n");
}
void radixsort(int n)
{
int tmp;
for(int k=0; k<len; k++)
{
memset(c,0,sizeof(c)); //注意初始化啊啊啊啊啊啊啊
for(int i=1; i<=n; i++)
{
tmp=(a[i]/(int)pow(10.0,k))%10;
bucket[tmp][c[tmp]++]=a[i];
}
int p=1;
for(int i=0; i<10; i++)
{
for(int j=0; j<c[i]; j++)
a[p++]=bucket[i][j];
}
}
}
int main()
{
int n;
while(cin>>n)
{
init(n);
radixsort(n);
print(n);
}
return 0;
}
//STL版的桶排序
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#define N 100000
using namespace std;
vector<int>vec;
vector<int>::iterator point;
queue<int>que[10];
int n,Max,len;
void init()
{
int tmp;
Max = 0,len=0;
for (int i = 1; i <= n; i++)
{
cin >> tmp;
vec.push_back(tmp);
Max = max(Max,tmp);
}
while (Max)
{
Max /= 10;
len++;
}
}
void VecToDeque(vector<int>vec, queue<int>deq[], int n)
{
for (point = vec.begin(); point != vec.end(); ++point)
{
int itor = (*point) / n % 10;
deq[itor].push(*point);
}
}
void Collect(vector<int>&vect,queue<int>deq[])
{
int c = 0;
for (int i = 0; i < 10; i++)
{
while (!deq[i].empty())
{
vect[c++] = deq[i].front();
deq[i].pop();
}
}
}
void output()
{
for ( point = vec.begin(); point != vec.end(); ++point)
{
cout << *point << " ";
}
}
void RadixSort(vector<int>&vec)
{
int power = 1;
for (int i = 1; i < len; i++)
{
VecToDeque(vec,que, power);
Collect(vec, que);
power *= 10;
}
}
int main()
{
while (cin >> n)
{
init();
RadixSort(vec);
output();
printf("\n");
}
return 0;
}