#C12296. Filter Prime Numbers

    ID: 41707 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 from the list and print them in the order they appear.

A prime number is defined as a natural number greater than \(1\) that has no positive divisors other than \(1\) and itself.

Your program should read the input from stdin and output the result to stdout.

inputFormat

The input consists of two lines:

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

outputFormat

Output a space-separated list of all prime numbers found in the given list. If no prime number exists, output an empty line.

## sample
8
2 3 4 5 10 17 18 19
2 3 5 17 19

</p>