#C4086. Find Prime Numbers

    ID: 47585 Type: Default 1000ms 256MiB

Find Prime Numbers

Find Prime Numbers

You are given a list of positive integers. Your task is to identify and output all the prime numbers that appear in the list, in the same order as they appear in the input.

A prime number is defined as an integer greater than 1 that has no positive divisors other than 1 and itself. In mathematical terms, a number \( n \) is prime if and only if \( n > 1 \) and for every integer \( a \) such that \( 2 \leq a \leq \sqrt{n} \), \( a \) does not divide \( n \) evenly.

You should implement an efficient function to check if a number is prime and then use it to filter the list.

inputFormat

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

outputFormat

Output a single line containing all the prime numbers from the input list in the same order as they appear, separated by a single space. If no prime numbers are present, output an empty line.

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

</p>