LogiQuest

76. Alternate Positive and Negative

MediumArray

The array has equally many positive and negative numbers. Rearrange so that positives and negatives alternate, starting with a positive, keeping the relative order inside each group.

Input format

Line 1: n (even) Line 2: n non-zero integers

Output format

The rearranged array.

Example 1

Input

6
3 1 -2 -5 2 -4

Output

3 -2 1 -5 2 -4

Example 2

Input

2
-1 1

Output

1 -1

Constraints

2 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…