#K65417. Filtering Prime Numbers from a List

    ID: 32193 Type: Default 1000ms 256MiB

Filtering Prime Numbers from a List

Filtering Prime Numbers from a List

You are given a list of integers. Your task is to filter out and output the prime numbers in the list. A prime number \(p\) is defined as an integer greater than 1 that has no positive divisors other than 1 and \(p\) itself. In other words, for a number \(p > 1\), if there is no integer \(d\) such that \(2 \le d \le \sqrt{p}\) with \(d\) dividing \(p\), then \(p\) is a prime number.

The input is provided via standard input and the output should be written to standard output. If there are no prime numbers in the input list, output an empty line (or no output).

Examples:

Input:
9
2 3 4 5 6 7 8 9 10
Output:
2 3 5 7

Input: 7 1 4 6 8 9 10 12 Output:

</p>

inputFormat

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

outputFormat

Output the prime numbers from the given list in their original order, separated by a single space. If no primes exist, output an empty line.

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