#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
struct node{
int data;
struct node *left=NULL;
struct node *right=NULL;
}*a;
void zx(struct node *t){
if(t==NULL) return;
zx(t->left);
v.push_back(t->data);
zx(t->right);
}
void hx(struct node *t){
if(t==NULL) return;
zx(t->left);
zx(t->right);
v.push_back(t->data);
}
node* cr(struct node *t,int c){
if(!t){
t=new struct node;
}else{
if(c<t->data){
t->left=cr(t->left,c);
}else{
t->right=cr(t->right,c);
}
}
return t;
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
int t;
cin>>t;
cr(a,t);
}
zx(a);
for(int i=0;i<v.size();i++){
cout<<v[i]<<" ";
}
}