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