Var a,min,max,i1,i2,i; m:array[1..10000] of longint; begin min:=1000000; readln(a); for i:=1 to a do begin read(m[i]); if m[i]>max then begin max:=m[i]; i2:=i; end; if m[i]<min then begin min:=m[i]; i1:=i; end; end; a:=m[i1]; m[i1]:=m[i2]; m[i2]:=a; end.
m:array[1..10000] of longint;
begin
min:=1000000;
readln(a);
for i:=1 to a do
begin
read(m[i]);
if m[i]>max then
begin
max:=m[i];
i2:=i;
end;
if m[i]<min then
begin
min:=m[i];
i1:=i;
end;
end;
a:=m[i1];
m[i1]:=m[i2];
m[i2]:=a;
end.