var A:
array[1..n] of integer;
i, j, n: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
for i := 1 to n - 1 do
for j := i+1 to n do
if (A[i] mod 2 = 0) and (A[j] mod 2 = 0) and (A[i] < A[j]) or (A[i] mod 2 = 1) and (A[j] mod 2 = 1) and (A[i] > A[j]) then
begin
swap(A[i], A[j]);
end;
writeln('Mang da sap xep la: ');
for i := 1 to n do
writeln(A[i]);
end.