D. Equalize the Remainders
time limit per test
3 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given an array consisting of n.
In a single move, you can choose any position 1.
Let's calculate a with that remainder.
Your task is to change the array in such a way that c0=c1=⋯=cm−1=nm.
Find the minimum number of moves to satisfy the above requirement.
Input
The first line of input contains two integers n.
The second line of input contains 0≤ai≤109), the elements of the array.
Output
In the first line, print a single integer — the minimum number of moves required to satisfy the following condition: for each remainder from nm.
In the second line, print any array satisfying the condition and can be obtained from the given array with the minimum number of moves. The values of the elements of the resulting array must not exceed 1018.
Examples
input
Copy
6 3 3 2 0 6 10 12
output
Copy
3 3 2 0 7 10 14
input
Copy
4 2 0 1 2 3
output
Copy
0 0 1 2 3