#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}Node;
Node *root=NULL;
Node *create(int num){
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=num;
    newnode->left=NULL;
    newnode->right=NULL;
    return newnode;
}
void *create(int num){
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=num;
    newnode->next=NULL;
    newnode->right=NULL;
    return nrewnode;
}
void *insert(Node *root,int num){
    if(root==NULL)
    return create(num);
    if(num >root->data)
    root->right=insert(right->data,num);
    else if(num < root->data)
    root->left=inser(left->data,num);
    return root;
}
void inOrder(Node *root){
    if(root==NULL){
        inOrder(root->left);
        printf("%d",&root->data);
        inOrder(root->right);
    }
}
Node *maximum(Node *root){
    if(root==NULL){
        return root;
    }
    else{
    maximum(root->right);
    return root;
    }
}
int main(){
   int itr,num,size;
   scanf("%d",&size);
   for(itr=1;itr<=size;itr++){
       scanf("%d",&num);
       root=insert(root,num);
   }
   inorder(root);
   maximum(root);
   return 0;
}