#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
typedef struct Node {
    char task[100];
    struct Node* prev;
    struct Node* next;
} Node;
Node* head = NULL;
Node* tail = NULL;
void insertTask(char* name)
{
    struct* newNode = (Node*)malloc(sizeof(Node));
    strcpy(newNode->task, name);
    newNode->next = NULL;
    newNode->prev = tail;
    if(tail)tail->next = newNode;
    else head = newNode;
    tail = newNode;
}
void deleteFirstTask(){
    if(!head)return;
    Node* temp = head;
    head = head->next;
    if(head)head->prev = NULL;
    else tail= NULL;
    free(temp);
}
void displayTask(){
    if(!head){
        printf("List is empty\n");
        return;
    }
    Node* current = head;
    while(current){
        printf("%s", current->task);
        if(current->next)printf(" ");
        current = current->next;
    }
    printf("\n");
}
int main()
{
    int n;
    scanf("%d",&n);
    char buffer[100];
    for(int i = 0; i < n; i++){
        scanf("%s", buffer);
        if(i == 0 && isdigit(buffer[0])){
            printf("Invalid input\n");
            return 0;
        }
        insertTask(buffer);
    }
    deleteFirstTask();
    displayTask();
    return 0;
}