#C13965. Filter Prime Numbers
Filter Prime Numbers
Filter Prime Numbers
You are given a list of n integers. Your task is to output a new list containing only the prime numbers from the original list, preserving their order. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. Note that numbers less than or equal to 1 are not prime.
Input Format: The first line of input contains an integer n (the number of elements). The second line contains n space-separated integers.
Output Format: Output a single line containing the filtered prime numbers separated by a space. If there are no prime numbers in the list, output an empty line.
For example, if the input is:
9 2 3 4 5 6 7 8 9 10
then the output should be:
2 3 5 7
inputFormat
The first line contains an integer n indicating the number of elements in the list. The second line contains n space separated integers.
outputFormat
Output a single line with the prime numbers from the list in the order they appear, separated by a space. Print an empty line if there are no primes.
## sample9
2 3 4 5 6 7 8 9 10
2 3 5 7
</p>