#include <stdio.h>
#include <stdlib.h>

struct Node {
    char data;
    struct Node* left;
    struct Node* right;
};


struct createNode(char ch){
    struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode->left = NULL;
    newNode->right = NULL;
    return newNode;
    
}


struct Node insertNode(struct Node* root, char ch, int i) {
    if(root == NULL) return createNode(ch);
    
    root->left = insertNode(root->left, ch, 2 * i + 1);
    root->right = insertNode(root->right, ch, 2 * i + 2);
    return root;
}


void postOrder(struct Node* root) {
    if(root == NULL) return;
    
    postOrder(root->left);
    postOrder(root->right);
    printf("%s ", root->data);
}


int main() {
    
    int n, i;
    if(scanf("%d", &n) != 1 || n < 1 || n > 26) {
        printf("Invalid input");
        return 0;
    }
    
    char arr[n];
    
    for(i = 0; i < n; i++) {
        scanf("%s", arr[i]);
    }
    
    for(i = 0; i < n; i++) {
        root = insertNode(root, arr[i]);
    }
    
    postOrder(root);
    
    
    return 0;
}