#include<stdio.h>
int main(){
    int n;
    if(scanf("%d",&n)!=1){
        return 0;
    }
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    int s1[10],s2[10];
    int top1=-1,top2=-1;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        s1[++top1]=x;
    }
    while(top1 !=-1){
        int temp=s1[top1--];
        while(top2!=-1 && s2[top2]>temp){
            s1[++top]=s2[top2--];
        }
        s2[++top2]=temp;
    }for(int i=0;i<=top2;i++){
        printf("%d",s2[i]);
        if(i !=top2) printf(" ");
    }
    return 0;
}