#CCBCHBAHAI0000043. Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)
Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)
Loại các số âm, giữ nguyên thứ tự (Remove Negative Numbers While Preserving Order)
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem
Given an integer array .
Remove every negative element, i.e. every . Zero and positive values must remain. The relative order of retained elements must not change.
Define
If , then
Print and .
Input
The first line contains integer . The second line contains exactly integers .
Output
Print the remaining size on the first line. If , print the resulting array on the second line.
Subtask
Subtask 1 (100 points): ; .
Example
Input
5
-2 0 5 -1 3
Output
3
0 5 3
Explanation
The negative values and are removed; remain in their original relative order.