#include <stdio.h>
#include <string.h>
#define get_byte(a,x) (((a)>>byte) & 255)
int v[500009],t[500009],n,i,cnt[256];
const int buff_size=4096;
char buff[buff_size];
int _i=buff_size;
int next_int(FILE * in)
{
char x,y,k=1;
int z=0;
if (_i==buff_size)
y=fread(buff,buff_size,1,in),_i=0;
x=1;
while ((x<48 || x> 57) && x!='-')
{
x=buff[_i];
_i++;
if (_i==buff_size)
{
y=fread(buff,buff_size,1,in);
_i=0;
}
}
while (x>=48 && x<=57 || x=='-')
{
if (x=='-')
k=-1; else
z=(z<<1)+(z<<3)+x-48;
x=buff[_i];
_i++;
if (_i==buff_size)
{
y=fread(buff,buff_size,1,in);
_i=0;
}
}
return z*k;
}
void sort(int *a ,int *b,int byte )
{
memset(cnt,0,sizeof(cnt));
for (i=0;i<n;++i)
cnt[get_byte(a[i],byte)]++;
for (i=1;i<256;++i)
cnt[i]+=cnt[i-1];
for (i=n-1;i>=0;--i)
b[--cnt[get_byte(a[i],byte)]]=a[i];
}
int main(int argc, char const *argv[])
{
freopen("algsort.in","r",stdin);
freopen("algsort.out","w",stdout);
n=next_int(stdin);
for (i=0;i<n;++i)
v[i]=next_int(stdin);
sort(v,t,0);
sort(t,v,8);
sort(v,t,16);
sort(t,v,24);
for (i=0;i<n;++i)
printf("%d ",v[i]);
fclose(stdin);
fclose(stdout);
return 0;
}