Dynamic Programming - Rod cutting modified version

We have an array of N rods , each having some length ai
Each matchstick has a corresponding cost with it.

The cost to reduce or increase a rod of length ai to some length aj is equal to |ai-aj |* cost(ai)

Example :
Rod lengths: 1,2
Cost for each : 10,20

Min cost=(20-10)*1 + (20-20)*2=10

If 10 was chosen , cost would have been 20 which is not minimum.

We have to make all the rods of equal length , and minimize the cost in this process.