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