#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node *prev, *next;
};
struct node* createNode(int data) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    if (newNode == NULL) {
        printf("Memory allocation failed");
        exit(0);
    }
    newNode->data = data;
    newNode->prev = NULL;
    newNode->next = NULL;
    return newNode;
}
int findLargest(struct Node* head) {
    if (head == NULL)
    return -1001;
    int max = head->data;
    struct Node* temp = head->next;
    while (temp != NULL) {
        if (temp != NULL) {
            if (temp->data > max)
            max = temp->data;
            temp = temp->next;
        }
        return max;
    }
    int main() {
        int n;
        scanf("%d", &n);
        if (n <= 0) {
            printf("Invalid input");
            return 0;
        }
        struct Node *head = NULL, *tail = NULL;
        for (int i = 0; i < n; i++) {
            int value;
            scanf("%d", &value);
            struct Node* newNode = createNode(value);
            if (head == NULL) {
                head = newNode;
                tail = newNode;
            } else {
                tail->next = newNode;
                newNode->prev = tail;
                tail = newNode;
            }
        }
        int largest = findLargest(head);
        printf("%d", largest);
        return 0;
    }
}