Athena on Zanzibar Island
View as PDFIn a far far away land called the island of Zanzibar, Athena the Software Engineer is typing away on another problem. Earlier that day, her boss gave her  pizzas with tanginess values of 
, tasking her with finding two pizzas 
 and 
 such that 
 and 
 is minimized. But lately, Athena has been very swamped with 
physics lab work from the University of Waterloo writing boring business reports, and doesn't have time to complete the job. Can you help her finish it before the deadline?
Constraints
Subtask 1 [10%]
Subtask 2 [90%]
No additional constraints.
Input Specification
The first line contains the integer .
The second line contains the space-separated integers .
Output Specification
Let  be the minimum possible value of 
 with the given input.
The first line should contain .
The second line should contain the space separated integers  such that 
. If there are multiple possible answers, output the one that minimizes 
.
Sample Input
10
-5 8 2 1 7 -3 -5 0 5 5
Sample Output
0
1 9
Sample Explanation
Taking the  and 
 pizzas results in the best possible sum of 
.
Comments