#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
    
}s1;
int pos=1,count=0,ans;
s1 *head=NULL,*tail=NULL;

void create(int num){
    s1 *new=(s1*)malloc(sizeof(s1));
    new->data=num;
    new->next=NULL;
    if(head==NULL){
        head=new;
        tail=new;
    }else{
        tail->next=new;
        tail=new;
    }
}

 void display(){
    s1 *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
}  


int search(int val){
    s1 *i;
    for(i=head;i!=NULL;i=i->next){
        if(i->data == val){
            count=1;
            ans=i->data;
            
           
        }
          pos++;
    }

int main(){
    int size,num,val;
    scanf("%d",&size);
    if(size<=0){
        printf("-1");
        return 0;
    }
    for(int i=1;i<=size;i++){
        if(!scanf("%d ",&num)){
            printf("-1");
            return 0;
        }
        create(num);
    }
    scanf("%d",&val);
   
     search( val);
     if(count == 0){
         display()
         return 0;
     }
     else{
         printf("-1");
     }
    }
    return 0;    
}