#include <stdio.h>
#include <stdlib.h>

typedef struct node{
    int data;
    struct node *left;
    struct node *right;
}Node;

Node *root=NULL;

Node *create(int num){
    if(num == 0){
        return NULL;
    }
    
    Node *newnode =(Node*)malloc(sizeof(Node));
     
    newnode->data=num;
    newnode->left=newnode->right=NULL;
    return newnode;
}

Node *build(int arr[], int n,int i){
     
     if(root==NULL){
         return NULL;
     }
     
     Node *root=create(arr[i]);
     root->left=build(arr,n,2*i+1);
     root->right=build(arr,n,2*i+2);
     
}

void inorder(Node *root){
    if(root==NULL){
        return;
    }
    inorder(root->left);
    printf("%d", root->data);
    inorder(root->right);
    
}

int main(){
    int n;
    scanf("%d", &n);
    if(n<0){
        printf("Invalid input");
        return 0;
    }
    int arr[n];
    for(int i=0; i<n; i++){
        if(scanf("%d", &arr[i])<0){
            printf("invalid input");
            return 0;
        }
        Node *root = build(arr,n,0)
        inorder(root);
    }
    return 0;
}