#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
	int data[101];
	struct node *next;
};
int delete(struct node *head)
{
  struct node *temp =head;
  struct node *t;
  while(temp->next != NULL)
  {
    t=temp;
    temp=temp->next;
  }
  free(t->next);
  t->next=NULL; 
}   
 int main(){
	int i,n,dl;
	scanf("%d",&n);
	struct node *p,*q,*head;
	q=malloc(sizeof(struct node));
	scanf("%d",&q->data);
	q->next=NULL;
	head=q;
	p=head;
	for(i=2;i<=n;i++){
		q=malloc(sizeof(struct node));
		scanf("%d",&q->data);
		q->next=NULL;
		p->next=q;
		p=p->next;
	}
	p=head;
	scanf("%d",&dl);
	for(i=0;i<dl;i++){
		delete(head);
	}
	while(p!=NULL){
		printf("%d ",&p->data);
		p=p->next;
	}
	return 0;
}