#C10366. Prime Number Extraction

    ID: 39563 Type: Default 1000ms 256MiB

Prime Number Extraction

Prime Number Extraction

You are given a list of integers. Your task is to extract all the prime numbers from the list, sort them in ascending order, and print them as space-separated values. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

The program should read input from standard input (stdin) and write the output to standard output (stdout). If there are no prime numbers in the list, output an empty line.

inputFormat

The first line contains an integer N, representing the number of elements in the list. The second line contains N space-separated integers.

outputFormat

Print the prime numbers found in the list in ascending order, separated by a single space. If no prime number exists, print an empty line.## sample

7
10 15 3 7 22 13 27
3 7 13