// editor4
#include<stdio.h>
#include<stdlib.h>

typedef struct bst
{
    int data;
    struct bst *left,*right;
}node;

node* create(int n)
{
    node *nd=(node*)malloc(sizeof(node));
    nd->data=n;
    nd->left=nd->right=NULL;
    return nd;

node *ins(node* root,int key)
{
   if(root==NULL)
   {
       return create(key);
   }
   if(n<root->data)
   {
       root->left=ins(root->left,key);
   }
   else
   {
       root->right=ins(root->right,key);
   }
   return root;
}

void inorder(node *root)
{
    if(root==NULL)
    {
        return;
    }
    inorder(root->left);
    printf("%d ",root->data);
    inorder(root->right);
}

int main()
{
    int n;
    node *root;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        int data;
        scanf("%d",&data);
        root=ins(data);
    }
    inorder(root);
}