var A:array[1..10000] of longint;
begin
write('N='); 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 max:=A[i];
if A[i]<min then min:=A[i];
end;
for i:=1 to n do
for j:=i+1 to n do
if A[i]>A[j] then begin t:=A[i]; A[i]:=A[j]; A[j]:=t; end;
write(min,' ',max);
for i:=1 to n do writeln(A[i]);
readln
end.
{ Bo sung phan khai bao:
Them phan nay vao khai bao
i,j,n,max,min:longint;
}