#C14918. Prime Filter

    ID: 44620 Type: Default 1000ms 256MiB

Prime Filter

Prime Filter

Given a list of integers, your task is to filter and print out only the prime numbers in their original order. A number ( n ) is said to be prime if and only if it is greater than 1 and has no positive divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers, whereas 4, 6, 8, 9, and 10 are not. Use efficient algorithms to determine the primality to handle larger inputs if needed.

inputFormat

The input is given via standard input. The first line contains a single integer ( N ) representing the number of integers. The second line contains ( N ) space-separated integers.

outputFormat

Output a single line containing all the prime numbers from the input in the order they appear, separated by a single space. If there are no prime numbers, output an empty line.## sample

5
11 14 17 19 21
11 17 19