**We have an array of N rods , each having some length a _{i}**

**Each matchstick has a corresponding cost with it.**

**The cost to reduce or increase a rod of length** a_{i} **to some length** a_{j} **is equal to** |a_{i}-a_{j} |* **cost**(a_{i})

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.**