#include<stdio.h>
#include<stdlib.h>


struct Node{
    int data;
    struct Node*Next;
};

void append(int value){
    Node*newnode=(struct Node*)malloc(sizeof(struct Node*))
    newNode->data=value;
    newNode->Next= NULL;
    
    if(head== NULL){
        head = newNode;
        return;
    }
    struct Node* temp = head;
    while (temp->Next! = NULL)
           temp = temp->next;
    temp->Next = newNode;
}

int insertAtPosition(int value, int pos, int n){
    if(pos<1 || pos>n+1)
        return 0;
        
    struct Node*newNode=(struct Node*)malloc(sizeof(struct Node));
           newNode->data = value;
           
           if(pos==1){
               newNode->Next = head;
               head = newNode;
               return 1;
           }
           
           struct Node*temp = head;
           for(int i=1;i<pos-1;i++)
              temp = temp->Next;
            newNode->Next = temp->Next;
            temp->Next = newNode;
            return 1;
}
  void display(){
      struct Node* temp = head;
      while(temp!=NULL){
          printf("%d", temp->data);
          if(temp->Next != NULL)
              printf(" ");
          temp = temp->Next;
      }
  } 
  int main(){
      int n, value,pos;
      scanf("%d",&n);
      
      for(int i=0;i<n;i++){
          scanf("%d",&value);
          append(value);
      }
      scanf("%d",&value);
      scanf("%d",%pos);
      
      if(insertAtPosition(value, pos,n))
          display();
      else
        printf("Invalid input");
        
      return 0;
  }
    
    
    
    
    
    
    
    
    
}