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