
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
int data;
struct Node *next;
} node;
node *creat(int n)
{
int i;
node * head,* p;
head=(node *)malloc(sizeof(node));
head->next=NULL;
for (i=0; i<n; i++)
{
p=(node *)malloc(sizeof(node));
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
}
return (head);
}
void output(node *head)
{
node * p;
p=head->next;
while(p!=NULL)
{
if (p->next==NULL)
printf("%d\n",p->data);
else
printf("%d ",p->data);
p=p->next;
}
}
int len(node *head)
{
int count=0;
node *p;
p=head->next;
while (p!=NULL)
{
p=p->next;
count++;
}
return count;
}
void idelete(node *head)
{
node *p,*q,*tp;
tp=head->next;
p=tp->next;
q=tp;
while (tp!=NULL)
{
p=tp->next;
q=tp;
while(p!=NULL)
{
if (p->data==tp->data)
{
q->next=p->next;
free(p);
p=q->next;
}
else
{
q=q->next;
p=p->next;
}
}
tp=tp->next;
}
}
int main()
{
int n;
node *head;
scanf("%d",&n);
head=creat(n);
printf("%d\n",len(head));
output(head);
idelete(head);
printf("%d\n",len(head));
output(head);
return 0;
}