#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
}s1;

s1 *create(int num){
    s1 *new=(s1*)malloc(sizeof(s1));
    new->data=num;
    new->left=new->right=NULL;
    return new;
}

s1 *insert(s1 *root,int num){
    if(root==NULL){
        return create(num);
    }else if(root->data>num){
        root->left=insert(root->left,num);
    }else{
        root->right=insert(root->right,num);
    }
    return root;
}

s1 *maximum(s1 *root){
    if(root==NULL){
        return root;
    }
    int max=0;
    while(root!=NULL){
        if(root->data>max){
            max=root->data;
            root=root->right;
        }
    }
    printf("%d",max);
}


int main(){
    int size,num;
    s1 *root;
    scanf("%d",&size);
    for(int i=0;i<size;i++){
        scanf("%d",&num);
        root=insert(root,num);
    }
    maximum(root);
    return 0;
}