#include <stdio.h>
#include <stdlib.h>
// Define the structure for a doubly linked list node
typedef struct Node {
    int data;
    struct Node* next;
    struct Node* prev;
} Node;
// Function to find the largest value in the doubly linked list
int findLargest(Node* head){
    int maxval = head->data;
    Node*current = head;
    while (current !=NULL){
        if (current->data > maxval){
            maxval = current->data;
        }
    current = current->next;
}
return maxVal;
}
// Function to create a doubly linked list from input values
Node* createDoublyLinkedLIst(int n, int*values){
    if (n <= 0) return NULL;
    Node* head = (Node*)malloc(sizeof(Node));
    head->data = values[0];
    head->prev = NULL;
    Node*current = head;
    for (int i = 1; i < n; i++){
        Node*newNode = (Node*)malloc(sizeof(Node));
         newNode->data = values[i];
         newNode->prev = current
         current->next = newNode;
         current = newNode;
    }
    current->next = NULL;
    return head;
}
int main(){
    int n;
    scanf("%d" , &n);
    if (n <= 0){
        printf("Invalid Input\n");
        return 0;
    }
    int*values = (int*)malloc(n* sizeof(int));
    for (int i = 0; i < n; i++){
        scanf("%d" , &values[i]);
    }
    Node*head = createDoublyLinkedList(n, values);
    int largest = findLargest(head);
    printf("%d\n" , largest);
    // Freeing memory
    Node* current = head;
    while (current !=NULL){
        Node* next = current->next;
        free(current);
        current = next;
    }
    free(values);
    return 0;
}
    }
    }
    }
}
}