var
i,n,a:integer;
begin
readln(n);
for i:=1 to n do
read(a);
if (a mod 3=0)and(a mod 5>0) then write(a,' ');
end;
writeln;
end.
var
i,n,a:integer;
begin
readln(n);
for i:=1 to n do
begin
read(a);
if (a mod 3=0)and(a mod 5>0) then write(a,' ');
end;
writeln;
end.