#K5366. Prime Number Filter

    ID: 29581 Type: Default 1000ms 256MiB

Prime Number Filter

Prime Number Filter

You are given an array of integers. Your task is to filter out the prime numbers from the array while preserving the original order of appearance.

Recall that a number (p) is prime if (p > 1) and its only positive divisors are 1 and (p). In mathematical notation: (p > 1 \text{ and } \forall d \in \mathbb{N},\ d|p \Rightarrow (d=1 \text{ or } d=p)).

inputFormat

The first line contains an integer (N) representing the number of elements in the array. The second line contains (N) space-separated integers.

outputFormat

Output the prime numbers from the array in the order that they appear, separated by a single space. If no prime numbers are found, output an empty line.## sample

5
15 3 8 11 2
3 11 2