#K63897. Filter Prime Numbers

    ID: 31855 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

Given a list of integers, your task is to output only the prime numbers in the order they appear in the list.

A prime number is a natural number greater than \(1\) that has no positive divisors other than \(1\) and itself. Formally, a number \(n\) is prime if and only if it satisfies:

\(n > 1\) and for every integer \(d\) with \(2 \leq d \leq \sqrt{n}\), \(d\) does not divide \(n\).

If there is no prime number in the provided list, output nothing.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

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

\(1 \leq n \leq 10^5\) and each integer may be positive, negative, or zero.

outputFormat

Output the prime numbers in the order they appear in the list, separated by a single space. If there is no prime number, output an empty line.

## sample
7
10 3 4 7 6 11 15
3 7 11