#include<stdio.h>
#define max 100000
struct sqlist
{
int data[max+1];
int lenth;
};
int patition(sqlist *l,int low,int high)
{
l->data[0]=l->data[low];
while(low<high)
{
while(low<high&&l->data[high]>=l->data[0])//找小于l->data[0]的数
{
high--;
}
l->data[low]=l->data[high];
while(low<high&&l->data[low]<=l->data[0])//找大于l->data[0]的数
{
low++;
}
l->data[high]=l->data[low];
}
l->data[low]=l->data[0];
return low;
}
void qusort(sqlist *l,int low,int high)
{
int p;
if(low<high)
{
p=patition(l,low,high);
qusort(l,low,p-1);
qusort(l,p+1,high);
}
}
int main()
{
sqlist l;
int i,lenth;
while(scanf("%d",&lenth)!=EOF)
{
l.lenth=lenth;
for(i=1;i<=lenth;i++)
{
scanf("%d",&l.data[i]);
}
qusort(&l,1,lenth);
for(i=1;i<lenth;i++)
{
printf("%d ",l.data[i]);
}
printf("%d\n",l.data[lenth]);
}
}