// editor5
#include<stdio.h>
#include<stdlib.h>
struct Node{
    ont data;
    struct Node*next;
};
struct Node*create(int data)
{
    struct Nod*n=(struct Node*)malloc(sizeof(struct Node));
    n->dat=data;
    n->next=NULL:
    return n;
}
int main()
{
    int n,x;
    scanf("%d",&n);
    struct Node*head=NUll,*tail=NULL,*temp;
    for(int i=0;i<n;i++)
    {
        scnaf("%d",&x);
        temp=create(x);
        if(!head)head=tail=temp;
        else{
            tail->next=temp;
            tail=temp;
        }
    }
    if(r=tail)tail->next=head;
    struct Node*curr=head,*prev=tail;
    int count=0;
    while(head&&count<n)
    {
        if(curr->data<0)
        {
            if(curr==head)
            {
                if(head->next==head)
                {
                    head=NULL;
                    break;
                }
                head=head->next;
                tail->next=head;
                free(curr);
                curr=head;
            }
            else{
                prev->next=curr->next;
                free(curr);
                curr=prev->next;
                
            }
            
        }
        else{
            prev=curr;
            curr=curr->next;
        }
        count++;
    }
    if(!head)
    printf("List is empty\n");
    else{
        temp=head;
        do{
            prinf("%d ",temp->data);
            temp=temp->next;
            
        }
        while(temp!=head);
        printf("\n");
        
    }
    return 0;
}