// editor2
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
    struct node *prev;
}nd;
nd *head=NULL,*tail;
void create(int num){
    nd *newnode=(nd*)malloc(1*sizeof(nd));
    newnode->data=num;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(head==NULL){
    head=newnode;
    tail=newnode;
}else{
    newnode->prev=tail;
    tail->next=newnode;
    tail=newnode;
}
}
int main(){
    int n,num;
    scanf("%d",&n);
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&num);
        create(num);
    }
    nd *temp=head;
    int max=temp->data;
    while(temp!=NULL){
        if(temp->data>max){
            max=temp->next;
        }
        temp=temp->next;
    }
    printf("%d",max);
    return 0;
}