CONST
 NUM = 10000;

var
 Ar	 : array [1..NUM] of word;
 i,j,tmp,Med : word;

procedure QSort(l,r:word);
begin
 if (r-l) <= 1 then
 begin
  if ar[l] < ar[r] then
  begin
   tmp := Ar[l];
   Ar[l] := Ar[r];
   Ar[r] := Tmp;
  end;
  exit;
 end;
 i := l;
 j := r;
 Med := Ar [(l+r) div 2];

 while j>=i do
 begin
  while (Ar[i]>Med) and (i<r) do inc(i);
  while (Ar[j]<Med) and (j>l) do dec(j);

  if (i<=j) then begin
    Tmp   := Ar[i];
    Ar[i] := Ar[j];
    Ar[j] := Tmp;
    inc(i);dec(j);
  end;
 end;

 if (j>l) then Qsort(l,j);
 if (i<r) then Qsort(i,r)
end;{QSort}

{------------------------------------}
BEGIN
Randomize;
  for i := 1 to NUM do Ar[i] := Random(65535);
  Qsort(1,NUM);
  For i := 0 to NUM-1 do 
  begin
   if (i mod 10) = 0 then WriteLn;
   Write(ar[i+1]:8);
  end;
END.