int main() {
    struct Node* head = NULL;
    int n, id;
    int valid_input = 1; // Flag to track input validity

    // Read n
    if (scanf("%d", &n) != 1) {
        valid_input = 0; // Not a valid integer
    }

    // Validate n
    if (n < 0 || n > 10) { // Constraints are -10 <= n <= 10, but problem implies positive n for input count
                             // Assuming n should be non-negative for valid input count
        valid_input = 0;
    }

    if (!valid_input) {
        printf("Invalid input\n");
        return 0;
    }

    // Read n participant IDs
    for (int i = 0; i < n; i++) {
        if (scanf("%d", &id) != 1) {
            valid_input = 0; // Not a valid integer
            break;
        }
        // Validate ID constraints
        if (id < -10000 || id > 10000) {
            valid_input = 0;
            break;
        }
        insertEnd(&head, id);
    }

    if (!valid_input) {
        printf("Invalid input\n");
    } else {
        printList(head);
    }

    // Free memory (optional for this problem, but good practice)
    struct Node* current = head;
    while (current != NULL) {
        struct Node* next = current->next;
        free(current);
        current = next;
    }

    return 0;
}