#K11726. Filter Non-negative Integers

    ID: 23533 Type: Default 1000ms 256MiB

Filter Non-negative Integers

Filter Non-negative Integers

You are given a list of integers. Your task is to filter out the negative integers and output only the non-negative ones. In other words, given a sequence of integers \(a_1, a_2, \dots, a_n\), output the subsequence consisting of all \(a_i\) such that \(a_i \ge 0\).

Input: The input begins with an integer \(N\) (\(0\le N\le 10^5\)) representing the number of elements, followed by a line containing \(N\) space-separated integers.

Output: Print a single line containing the non-negative integers in the same order as they appear in the input. If there are no non-negative integers, output an empty line.

For example, if the input is:

6
-5 3 7 -2 0 -1

Then the output should be:

3 7 0

inputFormat

The first line of the input contains an integer N indicating the number of integers. The second line contains N space-separated integers.

outputFormat

Output a single line containing all non-negative integers from the input, in their original order. If no non-negative integer exists, output an empty line.## sample

6
-5 3 7 -2 0 -1
3 7 0

</p>