#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int data;
    struct node *next;
}Node;
`
Node *head = NULL, *tail;

void create(int num){
    Node *newNode = (Node*) malloc (sizeof(Node));
    newNode->data = num;
    newNode->next = NULL;
    if(head == NULL){
        head = newNode;
        tail = newNode;
    }
    else{
        tail->next = newNode;
        tail = newNode;
        tail->next = head;
    }
}

void del(int val){
    Node *curr = head, *prev = tail;
    curr = head->next;
    while(curr != head){
        if(curr->data == val){
            prev->next = curr->next;
            if(curr == tail)
                t
            
            return;
        }
        first=first->next;
        second=second->next;
    }
    printf("Node not found");
}

void display(){
    Node *itr = head;
        
    do {
        printf("%d ",itr->data);
        itr=itr->next;
        
    }while(itr != head);
}

int main(){
    int size,num,val;
    scanf("%d",&size);
    for(int i=0;i<size;i++){
        scanf("%d",&num);
        create(num);
    }
    scanf("%d",&val);
    del(val);
    display();
}