#K49042. Filter Prime Numbers

    ID: 28554 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 and output them in ascending order. A number (p>1) is called prime if it has no divisors other than 1 and (p). Note that 1 is not considered a prime number.

For example, given the list [2, 3, 4, 5, 6, 7], the prime numbers are [2, 3, 5, 7].

inputFormat

The first line 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 found in the list in ascending order, separated by a single space. If there are no prime numbers, output an empty line.## sample

6
2 3 4 5 6 7
2 3 5 7