#K66227. Filter Prime Numbers

    ID: 32374 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

You are given a list of integers. Your task is to filter out the prime numbers from the list and print them in the order they appear. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. Note that the list may include negative numbers and zero, which are not considered prime numbers.

Input/Output Requirement: Read input from stdin and write the result to stdout.

Definition: A number \(n\) is prime if \(n > 1\) and it is not divisible by any natural number other than 1 and \(n\). For example, 2, 3, 5, and 7 are prime numbers.

inputFormat

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

outputFormat

Print the prime numbers extracted from the list, separated by a single space. If there are no prime numbers, output an empty line.

## sample
5
4 5 6 7 8
5 7