Time limit per test: 0.5
Memory limit: 262144
The swimming area of Berhattan's city beach is marked out with n
buoys. The buoys form a straight line. When the buoys were being put into the water, nobody cared to observe the same distance between each pair of adjacent buoys.
Now the beach keeper wants the distance between any two adjacent buoys to be the same. He plans to shift some or all of the buoys without changing their respective order. To facilitate the task, he wants the total length of all shifts to be as small as possible.
Given coordinates of the buoys, you should find the minimum possible length of all shifts, as well as new coordinates of the buoys.
The first line of input contains a single integer n
(2 ≤ n
≤ 400), n
— the number of buoys. The second line contains buoys' integer coordinates x1
(-10000 ≤ xi
≤ 10000). No two given buoys will share the same place. The coordinates are given in strictly increasing order.
To the first line print a real number t
— the minimum possible total length of required shifts. Output this value with at least 4 digits after the decimal point.
To the second line print n
numbers — new coordinates of the buoys. The new coordinates should be printed in strictly increasing order with at least 7 digits after the decimal point. If there are several optimal ways to shift the buoys, you may output any of them.
4 -2 2 6 9
-2.0000000000 1.6666666667 5.3333333333 9.0000000000
All buoys are located on the Ox
axis. You may move buoys only along the Ox