`#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

// Define a structure for a doubly linked list node
typedef struct BidNode {
    int bid;
    struct BidNode* prev;
    struct BidNode* next;
} BidNode;

// Function to create a new bid node
BidNode* createBidNode(int bid) {
    BidNode* newNode = (BidNode*)malloc(sizeof(BidNode));
    newNode->bid = bid;
    newNode->prev = NULL;
    newNode->next = NULL;
    return newNode;
}

// Function to insert a bid node into the doubly linked list
void insertBidNode(BidNode** head, BidNode** tail, int bid) {
    BidNode* newNode = createBidNode(bid);
    if (!*head) {
        *head = newNode;
        *tail = newNode;
    } else {
        (*tail)->next = newNode;
        newNode->prev = *tail;
        *tail = newNode;
    }
}

// Function to print the bid list in ascending order after manual sorting
void printBidList(BidNode* head) {
    BidNode* current = head;
    if (!current) {
        printf("List is empty\n");
        return;
    }
    // Manual sorting (bubble sort for simplicity)
    int swapped;
    BidNode* ptr1;
    BidNode* lptr = NULL;
    if (head == NULL)
        return;
    do {
        swapped = 0;
        ptr1 = head;
        while (ptr1->next != lptr) {
            if (ptr1->bid > ptr1->next->bid) {
                int temp = ptr1->bid;
                ptr1->bid = ptr1->next->bid;
                ptr1->next->bid = temp;
                swapped = 1;
            }
            ptr1 = ptr1->next;
        }
        lptr = ptr1;
    } while (swapped);
    // Print sorted bids
    while (current) {
        printf("%d", current->bid);
        current = current->next;
        if (current) printf(" ");
    }
    printf("\n");
}

// Function to check if input contains non-integer values
int isValidInput(char* bidsStr) {
    char* token = strtok(bidsStr, " ");
    while (token != NULL) {
        for (int i = 0; i < strlen(token); i++) {
            if (!isdigit(token[i])) return 0; // Invalid if non-digit found
        }
        token = strtok(NULL, " ");
    }
    return 1; // Valid input
}

int main() {
    int n;
    scanf("%d", &n);
    getchar(); // Consume newline
    char bidsStr[1000];
    fgets(bidsStr, sizeof(bidsStr), stdin);
    bidsStr[strcspn(bidsStr, "\n")] = 0; // Remove newline
    
    // Check for valid input
    if (!isValidInput(bidsStr)) {
        printf("Invalid input\n");
        return 1;
    }
    
    // Parse bids
    BidNode* head = NULL;
    BidNode* tail = NULL;
    char* token = strtok(bidsStr, " ");
    while (token != NULL) {
        insertBidNode(&head, &tail, atoi(token));
        token = strtok(NULL, " ");
    }
    
    printBidList(head);
    
    // Free memory (not shown for brevity)
    return 0;
}