#include<stdio.h>
#include<stdlib.h>

struct node{
    int data;
    struct node* next;
};
int main(){
    int n;
    scanf("%d",&n);
    
    if(n<=0){
        printf("Invalid input");
        return 0;
    }
    struct node*head=NULL;
    struct node*tail=NULL;
    
    for(int i=0;i<n;i++){
        int value;
        scanf("%d",&value);
        if(value<0){
            printf("Invalid input");
            return 0;
        }
        
        struct node*newnode=(struct node*)malloc(sizeof(node));
        newnode->data=value;
        newnode->next=NULL;
        
        if(head==NULL){
            head=newnode;
            tail=newnode;
        }
        else{
            tail->next=newnode;
            tail=newnode;
        }
    }
    
    struct node*temp=head;
    while(temp!=NULL){
        printf("%d",temp->data);
        if(temp->next!=NULL)
        printf(" ");
        temp=temp->next;
    }
    
    return 0;
}