#include <stdio.h>
#include <stdlib.h>
struct node{
    int data;
    struct node* next;
};
struct node*head = NULL;
struct node*temp;
struct node*temp1;
void create(int data){
    struct node* newnode=(struct node*)malloc(sizeof(struct node));
    newnode->data=data;
    newnode->next=NULL;
    if(head==NULL)
    {
        head=newnode;
    }
    else{
        temp=head;
        while(temp->next!=NULL)
        {
            temp=temp->next;
        }
        temp->next=newnode;
    }
}
void display(){
    temp=head;
    while(temp!=NULL)
    {
        printf("%d ",temp->data);
        temp=temp->next;
    }
}
void deletion(pos){
  
    temp=head;
    temp1=temp;
   
        while(temp!=NULL){
            if(temp->data==pos){
                temp1->next=temp->next;
            }
            free(temp);
            break;
        
        temp1->next=temp;
        temp=temp->next;
    }
}
int main(){
    int n,i,data;
     int pos;
    scanf("%d",&pos);
    if(scanf("%d",&n)!=1 || n<=0){
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<n;i++){
        if(scanf("%d",&data)!=1){
            printf("Invalid input");
            return 0;
            
        }
        create(data);
    }
   
     deletion(pos);
     display();
     return 0;
}