#C14287. Filter Prime Numbers

    ID: 43919 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

You are given an array of integers. Your task is to filter out and output the prime numbers from this list. A number \( p \) is considered prime if \( p > 1 \) and it has no divisors other than 1 and itself. In other words, \( p \) is prime if for every integer \( i \) with \( 2 \le i \le \sqrt{p} \), \( i \) does not divide \( p \).

The input is read from standard input (stdin) and the result should be printed to standard output (stdout) as a single line of space-separated prime numbers, in the order they appear in the array. If there are no prime numbers in the array, print an empty line.

inputFormat

The first line contains a single integer \( n \) representing the number of elements in the array. The second line contains \( n \) space-separated integers.

outputFormat

Output a single line that contains the prime numbers (space-separated) extracted from the array. If no primes are found, output an empty line.

## sample
5
2 3 4 5 6
2 3 5