program zadatak1;
var n,b,i,r,o,l,d,max,min:integer;
var a:array[1..1000000] of integer;

  begin
read(n);
for i:= 1 to n do
read (a[i]);
     if n= 2 then
     begin
       b:=a[1];
       a[1]:=a[2];
       a[2]:=b;
       write(a[1]);
          write(' ');
        write(a[2]);
     end
ELSE
begin





      l:=1;
      d:=2;
      o:=1;
      r:=2;


     while l<n do
      begin
           max:=a[o];
      for d:= o+1 to n do
      begin
       if a[d]>=max then
          begin
          max:=a[d];
          r:=d;
          end;

        end;
      if  a[o]<max  then l:=l+n
      else o:= o+1;

      end;



      i:=a[r];
      a[r]:= a[o];
      a[o]:= i;









  for i:= 1 to n do
  begin
  write (a[i]);
  write(' ');
  end;
  end;

  read(b);


  end.