#include <iostream>
using namespace std;

int n;

struct Node{
    int data;
    Node* next;
    Node(int x): data(x), next(NULL){}
};

int main() {
    while(cin >> n)
    {
        int data;
        Node* root = new Node(-1);
        while(n--)
        {
            cin >> data;
            
            Node* pre = root;
            Node* node = pre->next;
            while(node != nullptr)
            {
                if(node->data < data)
                {
                    pre = node;
                    node = node->next;
                }
                else break;
            }
            Node* tmp = new Node(data);
            pre->next = tmp;
            tmp->next = node;
        }
        while(root->next != nullptr)
        {
            cout << root->next->data << " ";
            root = root->next;
        }
    }
}