program random;
var
a:array[1..100]of integer;
n,m,x,i,j,k:integer;
f1,f2:text;
begin
assign(f1,'random.in');reset(f1);
assign(f2,'random.out');rewrite(f2);
readln(f1,n);
fillchar(a,sizeof(a),0);
m:=1;
read(f1,a[1]);
for i:=2 to n do begin
read(f1,x);
j:=1;
while (j<=m)and(x>a[j]) do inc(j);
if (x<>a[j+1])and(x<>a[j]) then begin
for k:=m+1 downto j+1 do a[k]:=a[k-1];
a[j]:=x;
inc(m);
end;
end;
close(f1);
writeln(f2,m);
for i:=1 to m do write(f2,a[i],' ');
close(f2);
end.