#C5853. Filtering Prime Numbers

    ID: 49548 Type: Default 1000ms 256MiB

Filtering Prime Numbers

Filtering Prime Numbers

Given a list of integers, your task is to filter out only the prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In mathematical terms, a number \(p\) is prime if \(p > 1\) and for any integer \(a\) such that \(1 < a < p\), \(a\) does not divide \(p\).

The input is read from stdin where the first line is an integer \(n\) representing the number of elements in the list, followed by a line containing \(n\) space-separated integers. The output should print the prime numbers in the order they appear in the input, with a single space between numbers. If there are no prime numbers, output an empty line.

inputFormat

The first line contains a single integer \(n\) — the number of integers in the list. The second line contains \(n\) space-separated integers.

outputFormat

Print the prime numbers from the input list, separated by a space. If no prime numbers exist in the list, output an empty line.

## sample
5
2 3 5 7 11
2 3 5 7 11