#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int a[1001];
struct node{
int data;
node* lchild;
node* rchild;
};
//新建结点
node* newNode(int v)
{
node* Node=new node;
Node->data=v;
Node->lchild=Node->rchild=NULL;
return Node;
}
//插入结点
void insert(node* &root,int x)
{
if(root==NULL)
{
root=newNode(x);
return;
}
if(x==root->data)
return;
else if(x<root->data)
insert(root->lchild,x);
else
insert(root->rchild,x);
}
//创建树
node* create(int data[],int n)
{
node* root=NULL;
for(int i=0;i<n;i++)
{
insert(root,data[i]);
}
return root;
}
void pre(node* root)
{
if(root==NULL)//遍历条件又忘了加
return;
printf("%d",root->data);
pre(root->lchild);
pre(root->rchild);
}
int main()
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%d",&a[i]);
}
node* root=create(a,t);
pre(root);
return 0;
}