// editor1
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
    int data;
    struct node *left,*right;
    
}Node;
Node *root=NULL;

Node* create(int num){
    Node *newNode=(Node*)malloc(sizeof(Node));
    newNode->data=num;
    newNode->left=NULL;
    newNode->right=NULL;
    return newNode;
    
}

Node* insert(Node *root,int num){
    if(root==NULL)
        return create(num);
    if(num<root->data)
        root->left=insert(root->left,num);
    else if(num>root->data)
        root->right=insert(root->right,num);
    return root;
    
}
Node *minimum(Node *root){
    if(root==NULL){
        return root;
        
    }
    if(root->left=NULL)
        return minimum(root->left);
    return root;
}

Node *deletion(Node *root,int num){
    if(root==NULL)
        return root;
    if(num<root->data)
        root->left=deletion(root->left,num);
    if(num>root->data)
        root->right=deletion(root->right,num);
    else if(num>root->data)
        root->right=deletion(root->right,num);
    else{
        if(root->letf==NULL && root->right==NULL)
            return NULL;
        else if(root->left!=NULL && root->right==NULL)
            return root->left;
        else if(root->left==NULL && root->right!=NULL)
            return root->right;
        else{
            Node *temp = minimum(root->right);
            root->data = temp->data;
            root->right = deletion(root->right,temp->data);
        }
    }
    return root;
    
}
int main(){
    int size,num,itr,val;
    scanf("%d",&size);
    for(itr=1;itr<=size;itr++){
        scanf("%d",&num);
        root = insert(root, num);
    }
    scanf("%d",&val);
    if(search(root,val)=NULL){
        printf("-1");
        return 0;
    }
}