#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
    struct node *prev;
}node;
node *head=NULL,*tail;
void create(int num){
    node *newnode=(node*)malloc(1*sizeof(node));
    newnode->data=num;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(head==NULL){
        head=newnode;
        tail=newnode;
        
    }
    else{
        newnode->prev=tail;
        tail->next=newnode;
        tail=newnode;
    }
}

void insert(node *first,int val){
    node *first=val;
    first->next=head->prev;
    head=first;
}

void display(){
    printf("%d ",first->data);
    node *i;
    for(i=tail;i!=head->prev;i=i->prev){
        printf("%d ",i->data);
    }
    
}

int main(){
    int n,ele,val;
    scanf("%d",&n);
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<n;i++){
        scanf("%d",&ele);
        create(ele);
    }
    scanf("%d",&val);
    insert(val);
    
    display();
    return 0;
  
}