var a:array[1..30] of longint;
i,n,tam,j:longint;
begin
readln(n); {nhập số lượng phần tử}
for i:=1 to n do readln(a[i]);{nhập các phần tử theo hàng dọc}
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
if (a[i] mod 5=0) and (a[i] mod 2=1) then
write(a[i],' ');writeln;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i],' ');writeln;
readln
end.