#K36907. Filter Prime Numbers

    ID: 25858 Type: Default 1000ms 256MiB

Filter Prime Numbers

Filter Prime Numbers

Problem Description: You are given a list of integers. Your task is to filter out the prime numbers from this list and output them in the order they appear.

A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. In other words, a number \( n \) is prime if and only if \( n > 1 \) and there is no integer \( d \) with \( 2 \leq d \leq \sqrt{n} \) such that \( d \) divides \( n \).

You need to implement the filtering of prime numbers based on the above definition.

inputFormat

The input consists of two lines:

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

outputFormat

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

## sample
9
2 3 5 7 11 13 17 19 23
2 3 5 7 11 13 17 19 23