#K57197. Organize Integer List
Organize Integer List
Organize Integer List
Given a list of integers, your task is to reorganize the list such that negative numbers come first, followed by zeros, and then positive numbers. The original relative order among negative numbers and among positive numbers must be maintained.
The reordering can be illustrated as follows:
$$ result = \text{negatives} \Vert \text{zeros} \Vert \text{positives} $$
You are expected to read the input from standard input and write the output to standard output.
inputFormat
The first line of input contains an integer n
denoting the number of elements in the list.
The second line contains n
space-separated integers.
outputFormat
Output the reorganized list on a single line, with each integer separated by a single space.
## sample9
4 -1 0 5 -3 0 2 -7 1
-1 -3 -7 0 0 4 5 2 1
</p>