uses crt;
var a: array[1..100] of integer;
i,n,j,s,t: integer;
begin
clrscr;
write ('nhap n: '); readln (n);
for i:=1 to n do
begin
write ('nhap phan tu thu ',i,': '); readln (a[i]);
s:=s+a[i];
end;
writeln ('day vua nhap la: ');
for i:=1 to n do write (a[i]:3);
writeln;
for i:=1 to n-1 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;
writeln ('cac phan tu chan theo thu tu tang dan la: ');
for i:=1 to n do
if a[i] mod 2=0 then write (a[i]:3);
writeln;
for i:=1 to n-1 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;
writeln ('cac phan tu le theo thu tu giam dan la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write (a[i]:3);
writeln;
writeln ('tong cac phan tu la: ',s);
readln;
end.