// editor3
#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,d;
	scanf("%d",&n);
	if(n<=1||n>=1000)
	{
	    printf("Invalid input");
	    return 0;
	}
	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",&d);
	for(i=0;i<d;i++)
	{
		delete(head);
	}
	
	if(head->next==NULL)
	{
	    printf("List is empty");
	    return 0;
	}
	while(p!=NULL)
	{
		printf("%d ",p->data);
		p=p->next;
	}
	return 0;
}