#include <stdio.h>
#include <stdlib.h>
struct Node {
    int data;
    struct Node *next;
};
int main() {
    int n, max;
    scanf("%d", &n);
    struct Node *head = NULL, *tail = NULL, *temp;
    for (int i = 0; i < n; i++) {
        temp = (struct Node *)malloc(sizeof(struct Node));
        scanf("%d", %temp->data);
        temp->next = NULL;
        if (!head)
            head = tail = temp;
        else {
            tail->next = temp;
            tail = tamp;
        }
    }
    scanf("%d", &max);
    while (head && head->data > max) {
        head = head->next;
    }
    temp = head;
    while (temp) {
        printf("%d ", temp->data);
        temp = temp->next;
    }
    return 0;
}