IntermediateRating 1200
Alternate Positive and Negative
Rearrange the numbers to alternate positive, negative, positive, … keeping the order within each group. When one group runs out, append the rest of the other. Zero counts as positive.
Input
n, then n integers.
Output
n integers.
Sample 1
Input
6 1 2 3 -4 -1 4
Output
1 -4 2 -1 3 4
Sample 2
Input
3 -1 -2 5
Output
5 -1 -2
Output appears here