#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
    struct node *prev;
}s2;

s2 *head=NULL,*tail=NULL;
s2 *temp=NULL;

void create(int num){
    s2 *new=(s2*)malloc(sizeof(s2));
    new->data=num;
    new->prev=NULL;
    new->next=NULL;
    if(head==NULL){
        head=new;
        tail=new;
    }else{
        tail->next=new;
        new->prev=tail;
        tail=new;
    }
}
void display1(){
    s2 *i;
    for(i=head;i!=NULL;i=i->next){
        printf("%d ",i->data);
    }
    printf("\n");
}

void display(){
    s2 *temp,j;
    temp=head;
    for(temp=head;temp!=NULL;temp=temp->next){
        flag=0;
        for(j=head;j!=NULL;j=j->next){
            if(temp->data==j->data){
                flag=1;
            }
        }
        if(flag==0){
            printf("%d ",temp->data);
        }
    }
    
 }
int main(){
    int size,num;
    
    scanf("%d",&size);
    if(size<0){
        printf("Invalid input");
        return 0;
    }
    for(int i=1;i<=size;i++){
        scanf("%d",&num);
        create(num);
    }
    
    display1();
    display();
    return 0;
}