#C13612. Filtering Prime Numbers

    ID: 43170 Type: Default 1000ms 256MiB

Filtering Prime Numbers

Filtering Prime Numbers

You are given a list of integers. Your task is to filter out only the prime numbers from the list and output them in the same order they appear. A prime number is defined as an integer ( p ) such that ( p > 1 ) and it has no divisors other than 1 and itself, i.e. ( \forall q \in \mathbb{Z}, q \mid p \Rightarrow (q = 1 \text{ or } q = p) ). Note that negative numbers, 0, and 1 are not considered prime.

inputFormat

The first line of input contains a single integer (N) ((0 \leq N \leq 10^5)), representing the number of elements. The second line contains (N) space-separated integers.

outputFormat

Output a single line containing all prime numbers from the input list in the same order they appear, separated by a space. If there are no prime numbers, output an empty line.## sample

9
2 3 4 5 6 7 8 9 10
2 3 5 7