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