#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
struct node{
    int data;
    struct node *next;
};

struct node *createnode(int data)
{
    struct node *newnode=(struct node *)malloc(sizeof(struct node));
    newnode->data=data;
    newnode->next=NULL;
    return newnode;
}

void append(struct node **head,int data)
{
    struct node *newnode=createnode(data);
    if(*head==NULL)
    {
        *head=newnode;
        return ;
    }
    struct node *temp=*head;
    while(temp->next!=NULL)
    {
        temp=temp->next;
    }
    temp->next=newnode;
}
void display(struct node *head)
{
    struct node *temp=head;
    while(temp!=NULL)
    {
        printf("%d",temp->data);
        if(temp->next!=NULL)
            printf(" ");
    }
    printf("\n");
}
int isvalidinteger(char str[])
{
    int i=0;
    if(str[0]=='-' || str[0]=='+')
        i=1;
    if(str[i]=='\0')
        return 0;
    for(;str[i]!='\0';i++)
    {
        if(!isdigit(str[i]))
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    if(scanf("%d",&n)!=1 || n<0 || n>10)
    {
        printf("Invalid input\n");
        return 0;
    }
    struct node *head=NULL;
    for(int i=0;i<n;i++)
    {
        char temp[10];
        if(scanf("%s",temp)!=1 || !isvalidinteger(temp))
        {
            printf("Invalid input\n");
            return 0;
        }
        int num=atoi(temp);
        if(num<-1000 || num>1000)
        {
            printf("Invalid input\n");
            return 0;
        }
        append(&head,num);
    }
    display(head);
    return 0;
}