#include<stdio.h>
const int LIST_INIT_SIZE=100;
const int LISTINCRMENT=10;
typedef int A;
typedef struct
{
A *elem;
int Length;
int Listsize;
int incrementsize;
}SqList;
void InitList(SqList &L,int maxsize=LIST_INIT_SIZE,int incresize=LISTINCRMENT)
{
L.elem=new A[maxsize];
L.Length=0;
L.Listsize=maxsize;
L.incrementsize=incresize;
}
void purge(SqList &L)
{
int i,j;
i=-1;
j=0;
while(j<L.Length)
{
if(j==0||L.elem[i]!=L.elem[j])
L.elem[++i]=L.elem[j];
j++;
}
L.Length=i+1;
}
int main()
{
int n,i;
SqList L;
InitList(L);
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&L.elem[i]);
L.Length++;
}
for(i=0;i<n;i++)
{
printf("%d ",L.elem[i]);
}
printf("\n");
purge(L);
for(i=0;i<L.Length;i++)
printf("%d ",L.elem[i]);
return 0;
}