#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    char data;
    struct node *left,*right;
}node;

node* create(char *ch){
    node* new=(node*)malloc(sizeof(node));
    new->data=ch;
    new->left=new->right=NULL;
    return new;
}

node* insert(node* root,char *ch){
    if(root==NULL){
        return create(ch);
    }else if(ch<root->data){
        root->left=insert(root->left,ch);
    }else{
        root->right=insert(root->right,ch);
    }
    return root;
}

node *postorder(node* root){
    if(root==NULL)
        return root;
    postorder(root->left);
    postorder(root->right);
    printf("%d ",root->data);
}

int main(){
    int size;
    char ch[10];
    node* root;
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=0;i<size;i++){
        scanf("%c",ch);
        root=insert(root,ch);
    }
    postorder(root);
    return  0;
}