Program HOC24;
var a: array[1..50] of integer;
i,j,n,k,d,tg: integer;
t: longint;
begin
write('N='); readln(n);
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i]>0 then t:=t+a[i];
end;
write('K='); readln(k);
write('Cac phan tu chan la : ');
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
writeln;
writeln('Tong cac phan tu duong la : ',t);
d:=0;
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Trong mang co ',d,' phan tu bang ',k);
write('Mang sau khi sap xep la : ');
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=1 to n do write(a[i],' ');
readln
end.