Var a:array[1..1000] of integer;
n,i,im,max:integer;
begin
readln(n);
for i:=1 to n do
read(a[i]);
writeln;
max:=a[1];im:=1;
for i:=1 to n do
if a[i]>max then
begin
max:=a[i];
im:=i;
end;
a[1]:=a[1]+a[im];
a[im]:=a[1]-a[im];
a[1]:=a[1]-a[im];
for i:=1 to n do
write(a[i],' ');
end.