#C7728. Filter and Sort Prime Numbers

    ID: 51631 Type: Default 1000ms 256MiB

Filter and Sort Prime Numbers

Filter and Sort Prime Numbers

You are given a list of integers. Your task is to filter out the prime numbers and then sort them in ascending order.

A number \(p\) is considered prime if and only if it is greater than 1 and its only divisors are 1 and \(p\) itself. For example, 2, 3, and 5 are prime numbers, while 1, 4, and 6 are not.

inputFormat

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

outputFormat

Output a single line containing the prime numbers sorted in ascending order and separated by spaces. If there are no prime numbers in the input, output an empty line.

## sample
8
29 15 3 11 2 42 37 91
2 3 11 29 37