// editor4
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
typedef struct Node{
    int data;
    struct Node*next;
    struct Node*prev;
}Node;
Node*createNode(int data){
    Node*newNode=(Node*)malloc(sizeof(Node));
    newNode->data=data;
    newNode->next=NULL;
    newNode->prev=NULL;
    return newNode;
}
void append(Node**head,Node**tail,int data){
    Node*newNode=createNode(data);
    if(*head==NULL){
        *head=*tail=newNode;
    }else{
        (*tail)->next=newNode;
        newNode->prev=*tail;
        *tail=newNode;
    }
}
void bubbleSortDescending(Node*head){
    if(head==NULL)return ;
    int swapped;
    Node*ptr;
    do{
        swapped=0;
        ptr=head;
        while(ptr->next!=NULL){
            if(ptr->data<ptr->next->data){
                int temp=ptr->data;
                ptr->data=ptr->next->data;
                ptr->next->data=temp;
                swapped=1;
            }
            ptr=ptr->next;
        }
    }while(swapped);
}
void removeMiddle(Node**head,Node**tail){
    if(*head==NULL)return ;
    int length=0;
    Node*temp=*head;
    while(temp!=NULL){
        length++;
        temp=temp->next;
    }
    int mid=length/2;
    temp=*head;
    for(int i=0;i<mid;i++){
        temp=temp->next;
    }
    if(temp->prev)
    temp->prev->next=temp->next;
    if(temp->next)
    temp->next->prev=temp->prev;
    if(temp==*head)
    *head=temp->next;
    if(temp==*tail)
    *tail=temp->prev;
    free(temp);
}
void print_ist(Node*head){
    if(head==NULL){
        printf("List is empty\n");
        return ;
    }
    Node*temp=head;
    while(temp!=NULL){
        printf("%d",temp->data);
        temp=temp->next;
    }
    printf("\n");
}
int isNumeric(char*str){
    for(int i=0;str[i];i++){
        if(!isdigit(str[i]))
        return 0;
    }
    return 1;
}
int main(){
    int n;
    if(scanf("%d",&n)!=1||n<1||n>1000){
        printf("Invalid input\n");
        return 0;
    }
    Node*head=NULL;
    Node*tail=NULL;
    for(int i=0;i<n;i++){
        char buffer[20];
        if(scanf("%s",buffer)!=1){
            printf("Invalid input\n");
            return 0;
        }
        if(!isNumeric(buffer)){
            printf("Invalid input\n");
            return 0;
        }
        int value=atoi(buffer);
        append(&head,&tail,value);
    }
    bubbleSortDescending(head);
    removeMiddle(&head,&tail);
    printList(head);
    return 0;
}