program zad2;
    var
    a:array[1..1000] of integer;
    n,i,f,l,d,max,p:integer;
begin
   read(n) ;
    for i:=1 to n do
        begin
          read(a[i]);
        end;

for l:=1 to n-1 do  begin
  max:=a[l];
    for d:=l+1 to n do
         if (max<a[d]) and (f=0) then begin
              f:=1;
              p:=a[d];
              a[d]:=a[l];
              a[l]:=p;
           end;

         end;
if n=2 then begin
   p:=a[1];
   a[1]:=a[2];
   a[2]:=p;
   write(a[1],' ', a[2]);
end else
for i :=1 to n do   write(a[i],' ');

  end.