Uses DOS;
Const n = 15000;
Var
  mas : array [1..n] of ^word;
  i : integer;
  inp,out : text;
  hour,minute,second,sec100 : word;
  hour1,minute1,second1,sec1001 : longint;
  hour2,minute2,second2,sec1002 : longint;
procedure QuickSort(left,right:word);
 var
  i,j:integer;
  x,y:word;
 begin
  i:=left;
  j:=right;
  x:=mas[left]^;
  repeat
     while (mas[i]^< x) and (i<right) do inc(i);
     while (x <mas[j]^) and (j>left)  do dec(j);
     if (i<=j) then
       begin
         y:=mas[i]^;
         mas[i]^:=mas[j]^;
         mas[j]^:=y;
         inc(i);
         dec(j);
       end;
  until i>j;

   if left<j  then QuickSort(left,j);
   if i<right then QuickSort(i,right);
 end;

Begin
  randomize;
  assign(inp,'main');
  assign(out,'res');
  Rewrite(inp);
  Rewrite(out);
  for i := 1 to n do
    begin

      mas[i]^ := random(maxint);
      Write(inp,mas[i]^,' ');
      if i mod 10 = 0 then WriteLn(inp);
    end;
  close(inp);
  GetTime(hour,Minute,Second,sec100);
  hour1 := hour;
  minute1 := minute;
  second1 := second;
  sec1001 := sec100;
  QuickSort(1,n);
  GetTime(hour,minute,second,sec100);
  hour2 := hour;
  minute2 := minute;
  second2 := second;
  sec1002 := sec100;
  hour1 := hour2 - hour1;
  minute1 := minute2-minute1;
  if minute1 < 0 then
    begin
      dec(hour1);
      minute1 := 60 + minute1;
    end;
  second1 := second2-second1;
  if second1 < 0 then
    begin
      dec(minute1);
      second1 := 60 + second1;
    end;
  sec1001 := sec1002 - sec1001;
  if sec1001 < 0 then
    begin
      dec(second1);
      sec1001 := 100 + sec1001;
    end;
  WriteLn;
  Write(Hour1,' часов ',Minute1,' минут ',second1,' секунд ',sec1001,' 100-х');
  ReadLn;
  for i := 1 to n do
    begin
      Write(out,mas[i]^,' ');
      if i mod 10 = 0 then WriteLn(out);
    end;
  close(out);
End.