{*******************************************}
{* Program Name: Random *}
{* Input File: random.in *}
{* Output File: random.out *}
{* Date: 2008.7.23 *}
{* Programmer: Peng Bo *}
{*******************************************}
program random;
type
s1=Array[1..100]of word;
s2=array[1..1000]of boolean;
var
s:s1;
c:s2;
n,m:byte;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure input;
var
f:text;
t:word;
i:byte;
begin
assign(f,'random.in');
reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,t);
c[t]:=true;
end;
close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure output;
var
f:text;
i:byte;
begin
assign(f,'random.out');
rewrite(f);
writeln(f,m);
for i:=1 to m do
write(f,s[i],' ');
close(f);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dr;
var
i:word;
begin
for i:=1 to 1000 do
if c[i]
then
begin
inc(m);
s[m]:=i;
end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure px(l,r:byte);
var
i,j:byte;
x,t:word;
begin
i:=l;
j:=r;
x:=s[(l+r)div 2];
repeat
while s[i]<x do
inc(i);
while x<s[j] do
dec(j);
if i<=j
then
begin
t:=s[i];
s[i]:=s[j];
s[j]:=t;
inc(i);
dec(j);
end;
until i>j;
if l<j
then
px(l,j);
if i<r
then
px(i,r);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
m:=0;
input;
dr;
px(1,m);
output;
end.
{End.}