#P5736. 【深基7.例2】质数筛

【深基7.例2】质数筛

Problem Description

Input nn positive integers, each not greater than 10510^5. Store them all in an array, remove the numbers that are not prime, and output the remaining primes in order.

Input Format

The first line contains a positive integer nn, indicating the number of integers.

The second line contains nn positive integers aia_i, separated by spaces.

Output Format

Output one line: print the remaining primes in aia_i in order, separated by spaces.

5
3 4 5 6 7
3 5 7

Hint

Constraints: 1n1001 \le n \le 100, 1ai1051 \leq a_i \leq 10^5.

Translated by ChatGPT 5