#include<stdio.h>
#include<stdlib.h>

struct Node{
    int data;
    struct Node *left, *right;
};

struct Node* createNode(int data){
    struct Node* newnode = (struct Node*)malloc(sizeof(struct Node));
    newnode->data = value;
    newnode->left = newnode->right = NULL;
    return newnode;
}

struct Node* insert(struct Node* root, int value){
    if(root == NULL)
        return createNode(value);
    
    if(value < root->data)
        root->right = insert(root->left, value);
    
    else
        root->right = insert(root->right, value);
        return root;
    
}

    void inorder(struct Node*root){
        if(root!=NULL){
            inorder(root->left);
            printf("%d ",root->data);
            inorder(root->right);
        }
    }


int main(){
    int n;
    scanf("%d",&n);
    
    int height;
    struct Node* root=NULL;
    
    for(i=0;i<n;i++){
        scanf("%d",&height);
        if(height<0){
            return 0;
        }
        root = insert(root,height);
    }
        inorder(root);
    return 0;
}