#include <stdio.h>
#include <stdlib.h>
typedef struct treenode{
    int data;
    struct treenode*left;
    struct treenode*right;
    
}node;
node*root=NULL;
node*create(int num){
          node*newnode=(node*)malloc(sizeof(node));
          newnode->data=num;
          newnode->left=newnode->right=NULL;
          return newnode;
      }
node*insertBST(node*root,int num){
        if(root==NULL){
             return create(num);
        }
        if(num<root->data){
             root->left=insertBST(root->left,num);
        }
        else{
            root->right=insertBST(root->right,num);
        }
        return root;
}
int *deletnode(node*root,int tar){
    if (root->left== NULL){
        node*temp=root->right;
        free(root);
        return temp;
    }
    else if(root->right==NULL){
        struct node*temp=root->left;
        free(root);
        return temp;
    }
    struct node*temp=findmin(root->left);
    root->data=temp->data;
    root->left=deletenode(root->left,temp->data,found);
}
return root;

int main(){
    int size,val,num,i;
    node*root=NULL;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
 
    for(i=0;i<size;i++){
        if(!scanf("%d",&num)){
            printf("Invalid input");
            return 0;
        }
        root=insertBST(root,num);
    }

       return 0;
}