#00021A

mit-indiv09-array

You are given an array A of n integers. You have to find another array B such that the array [] (ci = ai + bi, for 1 <= i= n) is:
• Strictly increasing.
• Sum of all |bi| is minimized.



InputThe first line of the input contains an integer n (1 <= n <= 5000). The second line of the input contains n space separated integers, each from the interval [−10^9 10^9]


OutputTo the first line of the output, write a single number s, where s = Sum of all |bi|. To the second line of the output write n space separated integers representing the elements of the array B. If there are multiple solutions, output any of them.



Input:
[c]4
1 1 1 1

Output:
4
-1 0 1 2

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.