#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
typedef struct node {
    int data;
    struct node *left,*right;
}Node;
Node* root=NULL;
Node* create(int value) {
    Node *newnode=(Node*)malloc(sizeof(Node));
    newnode->data=value;
    newnode->left=NULL;
    newnode->right=NULL;
    return newnode;
}
Node* insert(Node *root,int value) {
    if(root==NULL)
    return create(value);
    if(value<root->data)
       root->left=insert(root->left,value);
    if(value>root->data) 
       root->right=insert(root->right,value);
    return root;  
}
int findMin(Node* root) {
    if(root==NULL)
      return -1;
    while(root->left!=NULL)
      root=root->left;
    return root->data;
}
int isValidInteger(char *str) {
    if(str==NULL)return 0;
    while(*str=='-' || *str=='\n' || *str'\t')str++;
    if(*str=='\0')return 0;
    if(*str=='-' || *str=='+')str++;
    if(!isdigit(*str))return 0;
    while (*str) {
        if(*str=='\n' || *str==' ' || *str'\t')break;
        if(!isdigit(*str))return 0;
        str++;
    }
    return 1;
}
int main() {
    char input[100];
    int N,value;
    Node* root=NULL;
    if(fgets(input,sizeof(input),stdin)==NULL || !isvalidInteger(input)) {
        printf("Invalid input");
        return 0;
    }
    N=atoi(input);
    if(N<1 || N>1000) {
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<N;i++) {
        if(fgets(input,sizeof(input),stdin)==NULL || !isvalidInteger(input)) {
            printf("Invalid input");
            return 0;
        }
        value=atoi(input);
        root=insert(root,value);
    }
    printf("%d",findMin(root));
    return 0;
}