LogiQuest

167. Sort by Absolute Value

EasyCustom Sort

Sort by absolute value ascending; when absolute values tie, the negative number comes first.

Input format

Line 1: n Line 2: n integers

Output format

The sorted array.

Example 1

Input

5
-3 2 -1 3 1

Output

-1 1 2 -3 3

Example 2

Input

2
5 -5

Output

-5 5

Constraints

1 ≤ 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…