#include <stdio.h>
#include <stdlib.h>
typedef struct linknode{
    struct linknode * next;
    int value;
}linknode,*linklist;
int main() {
    int n=0;
    scanf("%d",&n);
    int a[n];
    linklist l=(linklist)malloc(sizeof(linknode));
    linknode *t=l;
    linknode* t1=l;
    t->value=-1;
    for(int i=0;i<n;i++){
        int temp;
        scanf("%d ",&temp);
        linknode *ln=(linklist)malloc(sizeof(linknode));
        ln->value=temp;
        while(t->value<temp&&t!=NULL){
            t1=t;
            t=t->next;
        }
        if(t==NULL){
            t1->next=ln;
            ln->next=NULL;
            t=l;t1=l;
        }else {
            t1->next=ln;
            ln->next=t;
            t=l;t1=l;
        }
    }
    t=t->next;
    while(t!=NULL){
        printf("%d ",t->value);
        t=t->next;
    }
    return 0;
}