// editor4
#include<stdio.h>
#include<stdlib.h>

typedef struct node 
{
    int data;
    struct node *next;
}node;
node *newnode,*tail,*head;

void create(int num)
{
    newnode =(node*)malloc(sizeof(node));
    newnode->next=NULL;
    newnode->data=num;
    if(head==NULL)
    {
        head=newnode;
        tail=newnode;
    }
    else{
        tail->next=newnode;
        tail=newnode;
    }
    
}

void display(int size)
{  node *t;
   for(t=head;t!=NULL;t=t->next)
   {
        printf("%d ",t->data);
   }
    printf("\n");
   
}

 void dup(){
     node *t=head;
     int f1=1;
     int haspre=0;
     int pre=0;
     while(t){
         if(!haspre || t->data != pre)
         {
             if(!f1) printf(" ");
             printf("%d",t->data);
             f1=0;
             pre=t->data;
             haspre=1;
         }
         t=t->next;
     }
     printf("\n");
 }
 void f(){
     node *t=head;
     while()
 }
int main()
{
    int size,i,n;
    scanf("%d",&size);
    if(size<0)
    {
        printf("Invalid input");
        return 0;
    }
    for(i=0;i<size;i++)
    {
        scanf("%d",&n);
        create(n);
    }
    display();
    dup();
    f();
    return 0;
}