function isPrime(n: integer): boolean;
var d: integer;
begin
d := 2;
while (d <= Round(Sqrt(n))) and (n mod d <> 0) do d += 1;
isPrime := d > Round(Sqrt(n))
end;
var N, a, i: integer;
begin
Read(N);
i := 1;
while i
begin
Read(a);
if isPrime(a) then Write(a, ' ');
inc(i)
end
end.