#include<bits/stdc++.h>
using namespace std;
struct node{
int value;
node *next;
};
int main(){
int n,m,x;
scanf("%d",&n);
node *now,*prev,*head,*p;
scanf("%d",&m);
head=new node;head->value=m;head->next=NULL;
now=head;
for(int i=2;i<=n;i++){
scanf("%d",&m);
p=new node;p->value=m;p->next=NULL;
now->next=p;
now=p;
}
scanf("%d %d",&m,&x);
now=head;
for(int i=1;i<=n;i++){
printf("%d ",now->value);
if(now->value==m){
printf("%d ",x);
}
prev=now;
now=prev->next;
}
delete now;
delete prev;
delete head;
return 0;
}