#C998. Find Prime Numbers in a List

    ID: 54132 Type: Default 1000ms 256MiB

Find Prime Numbers in a List

Find Prime Numbers in a List

Given a sequence of integers, extract all the prime numbers and output them in ascending order. A prime number is defined as an integer greater than 1 which has no divisors other than 1 and itself. Mathematically, a number \( p \) is prime if and only if \( p > 1 \) and there does not exist any integer \( q \) such that \( 1 < q < p \) and \( p \mod q = 0 \).

inputFormat

The first line of input contains a single integer \( n \) (\( 1 \leq n \leq 10^5 \)) representing the number of elements. The second line contains \( n \) space-separated integers.

outputFormat

Output the sorted prime numbers in one line separated by a single space. If no primes are found, output an empty line.

## sample
6
4 7 5 8 12 11
5 7 11