var a:array[1..10]of integer;
max,min,i,n,i1,i2:integer;
begin
readln(n);
for i:=1 to n do readln(a[i]);
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if a[i]>max then begin max:=a[i]; i1:=i; end;
if a[i]<=min then begin min:=a[i]; i2:=i; end;
end;
a[i1]:=a[i1]+a[i2];
a[i2]:=a[i1]-a[i2];
a[i1]:=a[i1]-a[i2];
for i:=1 to n do write(a[i],' ');
end.
var a:array[1..10]of integer;
max,min,i,n,i1,i2:integer;
begin
readln(n);
for i:=1 to n do readln(a[i]);
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if a[i]>max then begin max:=a[i]; i1:=i; end;
if a[i]<=min then begin min:=a[i]; i2:=i; end;
end;
a[i1]:=a[i1]+a[i2];
a[i2]:=a[i1]-a[i2];
a[i1]:=a[i1]-a[i2];
for i:=1 to n do write(a[i],' ');
end.