Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
i,min,k:integer;
Begin
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
write(a[i], ' ');
k:=0;
min:=0;
for i:=1 to n do
if((a[i] mod 2 = 0) and (a[i] mod 3 <> 0) )
then if (k = 0) then
begin
min:=a[i];
k:=1;
end
else if (a[i]
writeln('');
writeln(min);
End.