#include<stdio.h>
#include<stdlib.h>

struct Node {
    int key;
    struct Node*left;
    struct Node*right;
};
struct Node* createNode(int key) {
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode -> key=key;
    newNode->left = newNode->right = NULL;
    return newNode;
}
struct Node* insert(struct Node*root,int key) {
    if (root == NULL) {
        return createNode(key);
    }
    if (key<root->key) {
        root ->left = insert(root->left,key);
        
    } else {
        root->right=insert(root->right,key);
    }
    return root;
}
void inorder(struct Node*root) {
    if(root!=NULL) {
        inorder(root->left);
        printf("%d\n",root->key);
        inorder(root->right);
    }
int main() {
    int n,key;
    if (scanf("%d",&n) !=1 || n<0 || n>10) {
        printf("Invalid input\n");
        return 0;
    }
    struct Node*root = NULL;
    for (int i=0;i<n;i++) {
        if (scanf("%d",&key)!=1 || key < -100 || key > 100) {
            printf("Invalid input\n");
            return 0;
        }
        root = insert(root,key);
    }
    inorder(root);
    return 0;
}
}