// You are using GCC
#include<iostream>
using namespace std;
struct Node
{
    int data;
    Node* next;
    Node(int data)
    {
        this->data=data;
        this->next=null;
    }
};
Node* head=NULL;
Node* tail=NULL;

Node* insertAtEnd(Node *head,int data)
{
    Node* obj=new Node(data);
    if(head==NULL)
    {
        head=obj;
        tail=obj;
    }
    else
    {
        tail->next=obj;
        tail=tail->next;
    }
    return head;
};

Node* insertAtBegin(Node *head,int data)
{
    Node* obj=new Node(data);
    if(head==NULL)
    {
        head=obj;
        tail=obj;
    }
    else
    {
        obj->next=head;
        head=obj;
    }
    return head;
};


Node* insertAtRandom(Node *head,int data,int pos)
{
    Node* obj=new Node(data);
    if(head==NULL)
    {
        head=obj;
        tail=obj;
    }
    if(head==NULL)
    {
        return obj;
    }
    if(pos==0)
    {
        head=insertAtBegin(head,data);
    }
    else
    {
        Node* temp=head;
        for(int i=0;i<pos-1 && temp->next!=NULL;i++)
        {
            temp=temp->next;
        }
        obj->next=temp->next;
        temp->next=obj;
    }
    return head;
};


void printAll(Node *head)
{
    Node* temp1=head;
    while(temp1!=NULL)
    {
        cout<<temp1->data<<" ";
        temp1=temp1->next;
    }
}


int main()
{
    int N;
    cin>>N;
    int val[N];
    for(int i=0;i<N;i++)
    {
        cin>>val[i];
        head=insertAtEnd(head,val[i]);
    }
    int B;
    cin>>B;
       head=insertAtBegin(head,B);
   
    int E;
    cin>>E;
    
     head=insertAtEnd(head,E);
  
    
    int p;
    cin>>p;
    int R;
    cin>>R;
  
      head=insertAtRandom(head,R,p);
    
   
    
    printAll(head);
    return 0;
    
}