#include<stdio.h>
#include<stdlib.h>
typedef struct TreeNode
{
    int data;
    struct TreeNode*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(int n,node *node)
{
    if(root==NULL)
    {
        return;
    }
    if(n<root->data)
    {
        root->right=ins(n,root->left);
    }
    else
    {
        root->right=ins(n,root->right);
    }
    return root;
}
void inorder(TreeNode,*node)
{
    if(node==NULL)
    {
        return;
    }
    inorder(root->left);
    printf("%d ",node->data);
    inorder(root->right);
}
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++)
    {
        int data;
        scanf("%d",&data);
        node=ins(data,root)
    }
    inorder(root);
    return 0;
}