#K79112. Prime Number Filter

    ID: 35237 Type: Default 1000ms 256MiB

Prime Number Filter

Prime Number Filter

You are given a list of integers, and your task is to filter and output only the prime numbers from the list.

A prime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself. In mathematical notation, a number \( n \) is prime if and only if \( n > 1 \) and for every integer \( d \) satisfying \( 1 < d < n \), we have \( n \mod d \neq 0 \).

Your solution should read the input from standard input (stdin) and output the result to standard output (stdout) as described below.

inputFormat

The input consists of two lines.

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

It is guaranteed that \( n \geq 0 \). If \( n = 0 \), the second line may be empty.

outputFormat

Output a single line containing the prime numbers from the list in their original order, separated by a single space. If there are no prime numbers, print an empty line.

## sample
9
3 4 7 6 11 13 17 18 19
3 7 11 13 17 19

</p>