Var
begin
j:=0;
for i:=1 to 10 do read(a[I]);
for i:=1 to 10 do
if a[i] mod 5=0 then begin
j:=j+1;
b[j]:=a[i];
end;
for i:=1 to 10 do
if a[i] mod 5<>0 then begin
j:=j+1;
b[j]:=a[i];
end;
For i:=1 to j do write(a[i],` `);
Writeln();
For i:=1 to j-1 do
For c:=j-1 downto i do
If b[c]>b[c+1] do begin
k:=b[c];
B[c]:=b[c+1];
B[c+1]:=k;
end;
For i:=1 to j do write(b[i],` `);
End.