#C13317. Filter Prime Numbers

    ID: 42842 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

In this problem, you are given a list of integers. Your task is to identify the prime numbers among them and output these primes in ascending order. A number ( n ) is considered prime if it is greater than 1 and has no divisors other than 1 and itself. Formally, ( n ) is prime if ( n > 1 ) and for every integer ( i ) such that ( 2 \leq i \leq \lfloor \sqrt{n} \rfloor ), we have ( n \mod i \neq 0 ). If there are no prime numbers in the input, simply output an empty line.

inputFormat

The input is provided via standard input (stdin). The first line contains an integer ( N ), representing the number of elements in the list. The second line contains ( N ) space-separated integers.

outputFormat

Print the prime numbers found in the list in ascending order, separated by a single space. If no primes are found, output an empty line.## sample

5
15 3 7 10 24
3 7