#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char* argv[])
{
int i,n;
int num;
typedef struct node
{
int num;
struct node *next;
}
NODE;
NODE *root,*p,*pre,*r;
while(scanf("%d",&n) != EOF)
{
root = NULL;
for(i=1;i<=n;i++)
{
scanf("%d",&num);
if(root == NULL)
{
root = (NODE *)malloc(sizeof(NODE));
root->num = num;
root->next = NULL;
}
else
{
r = (NODE *)malloc(sizeof(NODE));
r->num = num;
r->next = NULL;
p = pre = root;
if(num <= root->num)
{
r->next = root;
root = r;
}
else
{
while(p && p->num < num)
{
pre = p;
p = p->next;
}
if(p == NULL)
{
pre->next = r;
r->next = NULL;
}
else
{
pre->next = r;
r->next = p;
}
}
}
}
for(i=1;i<n;i++)
{
printf("%d ",root->num);
root = root->next;
}
printf("%d\n",root->num);
}
return 0;
}