#include <iostream>
#include <cstddef>
using namespace std;
class Node
{
public:
int data;
Node *next;
Node(int d){
data=d;
next=NULL;
}
};
class Solution{
public:
Node* insert(Node *head,int data)
{
Node *temp = new Node(data);
if(head == NULL){
head = temp;
return head;
}
Node *q, *p;
p = head;
q = head -> next;
while(q){
p = q;
q = p -> next;
}
p -> next = temp;
return head;
}
void display(Node *head)
{
Node *start=head;
while(start)
{
cout<<start->data<<" ";
start=start->next;
}
}
};
int main()
{
Node* head=NULL;
Solution mylist;
int T,data;
cin>>T;
while(T-->){
cin>>data;
head=mylist.insert(head,data);
}
mylist.display(head);
}