Program chik; label 1; var a:array[1..1000]of integer; p,w,i,n,min,max,l:integer; begin read(n); for i:=1 to n do begin read(a[i]); end; min:=a[1];max:=a[1]; for i:=2 to n do begin if(a[i]>max)then begin max:=a[i]; goto 1; end; if(a[i]<min)then min:=a[i]; 1: end; p:=max;l:=min; for i:=1 to n do begin if(a[i]=max)then a[i]:=l; if(a[i]=min)then a[i]:=p; end; for i:=1 to n do begin write(a[i],' '); end; end.
label 1;
var a:array[1..1000]of integer;
p,w,i,n,min,max,l:integer;
begin
read(n);
for i:=1 to n do
begin
read(a[i]);
end;
min:=a[1];max:=a[1];
for i:=2 to n do
begin
if(a[i]>max)then begin
max:=a[i];
goto 1;
end;
if(a[i]<min)then min:=a[i];
1:
end;
p:=max;l:=min;
for i:=1 to n do
begin
if(a[i]=max)then a[i]:=l;
if(a[i]=min)then a[i]:=p;
end;
for i:=1 to n do
begin
write(a[i],' ');
end;
end.