#include<iostream> using namespace std; typedef struct node { int data; struct node* next; } node; void createList(node** L, int k) { node* p = *L; node* r = new node; r->data = k; node* q = p->next; while (q->data < k && q != NULL) { p = p->next; q = q->next; } p->next = r; r->next = q; } int main() { int n; cin >> n; node* L = new node; L->next = NULL; int k; for (int i = 0; i < n; i++) { cin >> k; createList(&L, k); } node* p = L->next; while (p != NULL) { cout << p->data << " "; p = p->next; } return 0; }