#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    struct Node*next;
}Node;
Node* createNode(int data){
    Node*newNode=(Node*)malloc(sizeof(Node));
    newNode->data=data;
    newNode->next=NULL;
    return 0;
}
Node*remove_taller_than(Node*head,int max_height){
    while(head&&head->data>max_height){
        Node*temp=head;
        head=head->next;
        free(temp);
    }
    Node*current=head;
    while(current&&current->next){
        if(current->next->data>max_height){
            Node* temp=current->next;
            current->next=current->next->next;
            free(temp);
        }else{
            current=current->next;
        }
    }
    return head;
}
void print_list(Node*head){
    if(!head){
        printf("Empty\n");
        return;
    }
    while(head){
        printf("%d ",head->data);
        head=head->next;
    }
    printf("\n");
}
int main(){
    int n;
    scanf("%d",&n);
    Node*head=NULL;
    Node*current=NULL;
    for(int i=0;i<n;i++){
        int data;
        scanf("%d",&data);
        if(!head){
            head=createNode(data);
            current=head;
        }else{
            current->next=createNode(data);
            current=current->next;
        }
    }
    int max_height;
    scanf("%d",&max_height);
    head=remove_taller_then(head,max_height);
    print_list(head);
    return 0;
}