uses crt;
var a : array[1..100] of integer;
var n,i,min,max,t,tl,j,tc,tg,tg1 : integer;
begin clrscr;
t:=0;tl:=0; tc:=0;
write('Nhap n:');
readln(n);
for i:=1 to n do begin
write('Nhap a[',i,']=');
readln(a[i]); end;
min:=a[1];
max:=a[1];
for i:=1 to n do
if min > a[i] then min:=a[i];
for i:=1 to n do
if max < a[i] then max:=a[i];
writeln('Gia tri lon nhat :', max);
writeln('Gia tri nho nhat :', min);
for i:=1 to n do t:=t+a[i];
writeln('Tong cac phan tu cua day :', t);
for i:=1 to n do
if a[i] mod 2 = 0 then tc:=tc+a[i]
else tl:=tl+a[i];
writeln('Tong cac phan tu chan :', tc);
writeln('Tong cac [han tu le :', tl);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i] > a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
writeln('Sap xep day tang la :');
for i:=1 to n do write(a[i]:3);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i] < a[j] then
begin
tg1:=a[i];
a[i]:=a[j];
a[j]:=tg1;
end;
writeln;
writeln('Sap xep day giam la :');
for i:=1 to n do write(a[i]:3);
readln
end.