#include <iostream>
using namespace std;
struct BinTree {
int data;
BinTree *left;
BinTree *right;
BinTree ( int key = 0 ) {
data = key;
left = right = NULL;
}
};
void Insert ( int key, BinTree *root ) {
BinTree *node = new BinTree ( key );
BinTree *tmp = root;
while ( 1 ) {
if ( key >= tmp->data ) {
if ( tmp->right == NULL ) {
tmp->right = node;
break;
} else
tmp = tmp->right;
} else {
if ( tmp->left == NULL ) {
tmp->left = node;
break;
} else
tmp = tmp->left;
}
}
}
void DLR ( BinTree *root ) {
if ( root == NULL )
return;
cout << root->data << " ";
DLR ( root->left );
DLR ( root->right );
}
void Free ( BinTree *root ) {
if ( root == NULL )
return;
Free ( root->left );
Free ( root->right );
delete root;
}
int main() {
int N, M;
while ( cin >> N ) {
cin >> M;
BinTree *treeA = new BinTree ( M );
for ( int i = 1; i < N; ++i ) {
cin >> M;
Insert ( M, treeA );
}
DLR ( treeA );
cout << endl;
Free ( treeA );
}
return 0;
}