#include <stdio.h>
#include <stdlib.h>
typedef struct node{
    int data;
    struct node *prev;
    struct node *next;
}nd;
nd *head=NULL,*tail,*newnode,*temp;
void create(int val){
    newnode=(nd*)malloc(sizeof(nd));
    newnode->data=val;
    newnode->prev=NULL;
    newnode->next=NULL;
    if(head==NULL){
        head=newnode;
        tail=newnode;
    }
    tail->next=newnode;
    tail=newnode;
    tail->next=head;
}
void deleteval(int val){
    nd *curr=head;
    nd *prev=curr->prev;
    nd *next=curr->next;
    if(head->data=val){
        curr=head->next;
        
    }
}
void display(){
    temp=head;
    while(temp!=NULL){
        printf("%d ",temp->data);
        temp=temp->next;
    }
    //printf()
}
int main(){
    int n,x,y;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        create(x);
    }
    scanf("%d",&y);
    //deleteval(y);
    display();
}