#C14793. Filter Prime Numbers

    ID: 44481 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 output them in the same order as they appear in the list.

A prime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself. Negative numbers, 0, and 1 are not considered prime.

The input will be provided through standard input and the output should be sent to standard output. If no prime number exists in the input, output an empty line.

Note: The order of the prime numbers in the output should be the same as their order in the input.

inputFormat

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

outputFormat

Print the prime numbers from the list separated by a single space, preserving the order from the input. If there are no prime numbers, print an empty line.## sample

5
2 3 5 7 11
2 3 5 7 11