题目描述
Problem Description
There are $ N $ integers $ A_1, A_2, ..., A_N $ written on a blackboard.
Repeat the following operation $ N-1 $ times to leave only one integer on the blackboard.
- Choose two integers $ x, y $ and erase them, then write a new integer $ x - y $.
Find the maximum possible value of the remaining integer and the sequence of operations to achieve this maximum value.
Input Format
The input is given from the standard input in the following format:
$ N $ $ A_1 $ $ A_2 $ $ ... $ $ A_N $
Output Format
Output the maximum possible value $ M $ of the remaining integer and the sequence of operations $ x_i, y_i $ to achieve this maximum value in the following format.
Here, $ x_i, y_i $ represent the integers $ x, y $ chosen in the $ i $th operation.
If there are multiple sequences of operations that achieve the maximum value, you may output any one of them.
$ M $ $ x_1 $ $ y_1 $ $ : $ $ x_{N-1} $ $ y_{N-1} $
Sample Input and Output
Sample Input #1
3
1 -1 2
Sample Output #1
4
-1 1
2 -2
Sample Input #2
3
1 1 1
Sample Output #2
1
1 1
1 0
Notes/Hints
Constraints
- $2 \leq N \leq 10^5$
- $-10^4 \leq A_i \leq 10^4$
- All inputs are integers
Sample Explanation 1
In the first operation, choosing $ x $ as $ -1 $ and $ y $ as $ 1 $ results in the integers $ (-2, 2) $ on the blackboard. In the second operation, choosing $ x $ as $ 2 $ and $ y $ as $ -2 $ results in the integer $ (4) $ on the blackboard. Thus, $ 4 $ is the only remaining integer, and no integer greater than $ 5 $ can be the only remaining integer, making this the maximum value.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分